PHP Error: mysql_fetch_assoc() .. Query runs fine in phpMyAdmin
<p>I am getting this error when I execute my page:</p>

<blockquote>
  <p>Warning: <code>mysql_fetch_assoc()</code>: supplied argument is not a valid MySQL result resource ...</p>
</blockquote>

<p>I have tried running the SQL directory on phpMyAdmin and it runs fine.</p>

<p>Here is the full code:</p>

<pre><code>&lt;?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);



?&gt;
</code></pre>

<p>Why I'm I getting this error?</p>
