Jump to content

mysql_fetch_row


Crashthatch

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.