Page 1 of 1

Small code change (getting sql values) yields warning..

Posted: Thu Dec 18, 2003 7:57 pm
by d3ad1ysp0rk

Code: Select all

$asql = "SELECT `author` FROM `rants` WHERE `id` = '$id' LIMIT 1";
$author = mysql_result(mysql_query($asql), 0,0) or die("Error.");
works, but

Code: Select all

$asql = "SELECT `author` FROM `rants` WHERE `id` = '$id' LIMIT 1";
$aquery = mysql_query($asql) or die("There is no author for this rant..");
$author = mysql_result($aquery);
gives:
Warning: Wrong parameter count for mysql_result() in /home/des404/public_html/xrants/rant.php on line 23
any idea what I'm doing wrong?

Posted: Thu Dec 18, 2003 8:45 pm
by Weirdan
mysql_result expects three parameters. try:

Code: Select all

$asql = "SELECT `author` FROM `rants` WHERE `id` = '$id' LIMIT 1"; 
$aquery = mysql_query($asql) or die("There is no author for this rant.."); 
$author = mysql_result($aquery,0,0);

Posted: Thu Dec 18, 2003 10:07 pm
by d3ad1ysp0rk
hmm ok, i thought that was only for query's inside results, thanks!