Crashthatch Posted May 1, 2003 Share Posted May 1, 2003 How do I use the mysql_fetch_row function? It seems to have worked in all of my other scripts, but not in this one. I get this error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:webpageswebphpquestmain.php on line 20 This is the offending line: $old_location = mysql_fetch_row(mysql_query(\"SELECT location FROM qu_user WHERE user=$cuser\")); I try to print the result like this: echo \"You have moved from $old_location\"; The same goes for mysql_fetch_object. I have a feeling I have overlooked somthing really simple, but I cant figure out what it is. Any help appriciated, thanks. Quote Link to comment Share on other sites More sharing options...
shivabharat Posted May 1, 2003 Share Posted May 1, 2003 $result = mysql_query("SELECT location FROM qu_user WHERE user=\'$cuser\'"); $old_location = mysql_fetch_row($result); This should fix the error! Quote Link to comment Share on other sites More sharing options...
metalblend Posted May 1, 2003 Share Posted May 1, 2003 Actually, crashthatch\'s method would work fine unless the query returned FALSE (meaning it failed; usually a syntax error). Try using quotes around $cuser in the query.. like this: $old_location = mysql_fetch_row(mysql_query("SELECT location FROM qu_user WHERE user=\'$cuser\'")); Hope that helps. Quote Link to comment Share on other sites More sharing options...
Crashthatch Posted May 2, 2003 Author Share Posted May 2, 2003 Cheers guys. I messed around in PHPmyadmin with quotes and spaces, then changed it to: $old_location = mysql_fetch_row(mysql_query (\"SELECT location FROM qu_user WHERE user = \'$cuser\' \")); I\'m sure I\'ll be back soon when I get another problem. \'til then. Quote Link to comment Share on other sites More sharing options...
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.