dcole.ath.cx 0 Posted December 15, 2007 Report Share Posted December 15, 2007 Can i get some help with this error, thanks. What is the problem? Is it that $result is giving it bad data or what?[error] PHP Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/file1.php on line 131, referer: http://example.com/file2.html126 // find input from MySQL127 $query = 'SELECT response, preceed FROM $assignedtable';128 $result = mysql_query($query);129 // gonecount counts the line were on in the MySQL DB130 $gonecount = 0;131 while(list($response,$preceed)= mysql_fetch_row($result)) {132 for($g=0; $g<$gonesize; $g++){133 if ($response == $gone[$g]) {134 $isgone[$g] = 1;135 $locgone[$g] = $gonecount;136 }137 }138 $gonecount++;139 } Quote Link to post Share on other sites
Ingolme 1,020 Posted December 15, 2007 Report Share Posted December 15, 2007 Are you sure $assignedtable exists and has the name of an existing table? Quote Link to post Share on other sites
boen_robot 107 Posted December 15, 2007 Report Share Posted December 15, 2007 I'm no expert in MySQL, but does it allow actually resolve any variable references?The way you have written it, $assignedtable is a variable that MySQL must resolve on its own, not a PHP variable, and again, I don't know if MySQL can do that, so this may be a valid query. If indeed you wanted to use a PHP variable there, you need to use double quotes instead of single ones, or concatenate the variable instead of embedding it. I think double quotes is the more elegant way i.e. $query = "SELECT response, preceed FROM $assignedtable"; Quote Link to post Share on other sites
Ingolme 1,020 Posted December 15, 2007 Report Share Posted December 15, 2007 The variable is resolved in PHP first, at least in my queries things like that work ok. Quote Link to post Share on other sites
boen_robot 107 Posted December 15, 2007 Report Share Posted December 15, 2007 The variable is resolved in PHP first, at least in my queries things like that work ok.Not if you use single quotes they don't. Single quotes disable variable resolution in strings. It's only available with double quotes. Unless the PHP MySQL extension is actually responsible of resolving the variable before sending the query to the MySQL engine, then what the MySQL engine receives is exactly what we see, not what we would like the query to resolve to. Quote Link to post Share on other sites
Ingolme 1,020 Posted December 16, 2007 Report Share Posted December 16, 2007 Well, that may be a solution, try using double-quotes instead. Quote Link to post Share on other sites
dcole.ath.cx 0 Posted December 16, 2007 Author Report Share Posted December 16, 2007 Thanks, using double quotes solved the problem. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.