Jump to content



  • Please log in to reply
3 replies to this topic

#1 Crashthatch

  • Members
  • PipPip
  • Member
  • 18 posts

Posted 01 May 2003 - 09:17 PM

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.

#2 shivabharat

  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 01 May 2003 - 09:30 PM

$result = mysql_query("SELECT location FROM qu_user WHERE user=\'$cuser\'");

$old_location = mysql_fetch_row($result);

This should fix the error!
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 metalblend

  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 01 May 2003 - 10:37 PM

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.

#4 Crashthatch

  • Members
  • PipPip
  • Member
  • 18 posts

Posted 02 May 2003 - 10:42 PM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users