Note that there are some explanatory texts on larger screens.

plurals
  1. POWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/795746/warning-mysql-fetch-array-supplied-argument-is-not-a-valid-mysql-result">Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result</a> </p> </blockquote> <p>I'm having a problem with this mysql code. I presume its a basic error in the $sqlx... line but I'm slightly lost.</p> <p>The code basically prints messages from a db Here is the code:</p> <pre><code>$sqls="SELECT username FROM social WHERE `adder`='$username'"; $results=mysql_query($sqls); $resulti= mysql_num_rows($results); if ($resulti==0) { echo "You haven't added anyone yet. Find some &lt;a href=\"/social/suggestions\"&gt;suggestions&lt;/a&gt;"; } $row=mysql_fetch_array($results); $sqlx="SELECT * FROM messages WHERE `sender` IN ($row)"; $resultx= mysql_query($sqlx); $resultz= mysql_num_rows($resultx); if ($resultz==0){ echo "No messages at all!!"; } else { $finished="false"; $r=0; While(($rowx=mysql_fetch_assoc($resultx))&amp;&amp;($finished=="false")) { //echo off messages </code></pre> <p>$username is got further up the file.</p> <p>Here is the error:</p> <p>Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/public_html/social/iframe/index.php on line 34</p> <p>Line 34 is <code>$resultz= mysql_num_rows($resultx);</code> But like i said the error is probably the line two up from that.</p> <p>One interesting happens. "No messages at all!!" is echoed out which means the result of the <code>mysql_query</code> is 0. This is why I am convinced it is the line 32, (<code>$sqlx</code>)</p> <p>Any idea??</p> <p>Have I done the <code>mysql_fetch_array</code> wrong when getting <code>$row</code>?? thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload