I am getting this error when I execute my page:
Warning:
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource ...
I have tried running the SQL directory on phpMyAdmin and it runs fine.
Here is the full code:
<?php
$connect_error = 'Sorry, we have connection problems.';
mysql_connect('localhost','user','password') or die($connect_error);
mysql_select_db('mydb') or die($connect_error);
$result = mysql_query("SELECT * FROM tbl_main ORDER BY id desc limit 1");
 $rows = array();
   while($r = mysql_fetch_assoc($result)) {  //ERROR POINTS HERE
     $rows['id'][] = $r;
   } 
 print json_encode($rows);
?>
Why I'm I getting this error?
 
    