0

Im trying to fetch an array out of a Mysql query result :

    $result = mysqli_query($con,"SELECT * FROM names");

    if (!$result) {
   echo "WRONG";
}
    var_dump($result);

      //Fetch the data in a loop
      while($r=mysql_fetch_array($result, MYSQL_ASSOC)){

        var_dump($r);

      }

var_dump($result); shows me that there is something in it :

object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(6) ["lengths"]=> NULL ["num_rows"]=> int(2) ["type"]=> int(0) }

but why i never get a:

var_dump($r); call

1
  • 1
    you are mixing mysqli with mysql. Commented Apr 25, 2014 at 9:27

2 Answers 2

2

You are mixing mysql_ functions with mysqli_ functions

Change your fetch to

$r = mysqli_fetch_array()
Sign up to request clarification or add additional context in comments.

Comments

1

You did mistake in mysql_fetch_array while($r=mysqli_fetch_array($result, MYSQL_ASSOC)){

    var_dump($r);//write mysqli_fetch_array

  }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.