Page 1 of 1

a little trouble with mysql_result

Posted: Fri Aug 27, 2004 10:21 am
by jonah
I am trying to assign query output to variables in the standard way:

$result=mysql_query("SELECT * FROM Table1 WHERE Ident=$str",$db);

$ident=mysql_result($result,0,"Ident");
$user=mysql_result($result,0,"Username");
$pass=mysql_result($result,0,"Password");
$pin=mysql_result($result,0,"Pin");
$alt=mysql_result($result,0,"Alt");
$lot=mysql_result($result,0,"Lot");

The only difference between this coding and a more generalized
query is that I am not using a counter variable ($i) to iterate over
several records. This query only returns a single record.

I keep getting the error message:

PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource

Is there any reason why I cannot simply use the index '0' here to
assign the results? Or is something else wrong (like bad query)?

Posted: Fri Aug 27, 2004 10:36 am
by feyd
you likely have an error in your mysql_query call.. standard troubleshooting of queries:

Code: Select all

$result = mysql_query("SELECT * FROM Table1 WHERE Ident=$str",$db) or die(mysql_error());