Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
1  
you are mixing mysqli with mysql. –  Abhik Chakraborty Apr 25 at 9:27

2 Answers 2

You are mixing mysql_ functions with mysqli_ functions

Change your fetch to

$r = mysqli_fetch_array()
share|improve this answer

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

    var_dump($r);//write mysqli_fetch_array

  }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.