Note that there are some explanatory texts on larger screens.

plurals
  1. PO'Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in...' but my query is correct
    text
    copied!<p>Ok, so I know the question about 'why am I getting this warning with mysql_fetch_array...' has been asked several times, my problem is all the accepted answers state that the reasons the server is spitting this warning out is because the query itself is incorrect...this is not the case with me.</p> <p>Here is the code below:</p> <pre><code>$dbhost = "host"; $dbuser = "user"; $dbpass = "pass"; $dbname= "db"; $conn = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname) or die ('&lt;META HTTP-EQUIV="Refresh" CONTENT="0;URL=Failed.php?dberror=1"&gt;'); $token = mysql_escape_string($_GET['token']); $query = "SELECT * FROM newuser WHERE token='$token'"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql_fetch_array($result)) { do stuff... } </code></pre> <p>Everything within the 'while' statement is being executed just fine - it makes some changes to the DB which I can validate is happening. More importantly, the query never spits out any error details. I've tried testing for cases where $result===false and asking for error info but it won't return anything then either. From what I can tell, the query string is fine and is not failing.</p> <p>What am I doing wrong here? Could there any other reason why PHP doesn't like my While parameters other than the SQL statement is bad (which again, I'm convinced it's not bad)?</p> <p>Also, I know I should be using mysqli/PDO....I plan to switch over to that in the near future, but I'm pulling my hair out just trying to make this work and I have no idea why it won't. It's more of a personal thing at this point...</p> <p>Thanks for your help, and let me know if you need any additional info. (PHP Version 5.3)</p> <p>Here is an echo of the query string ($query): </p> <pre><code> SELECT * FROM newuser WHERE token='6e194f2db1223015f404e92d35265a1b' </code></pre> <p>And here is a var_dump of the query results ($result): resource(3) of type (mysql result)</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