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)?
a little trouble with mysql_result
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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());