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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

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

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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);
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

hmm ok, i thought that was only for query's inside results, thanks!
Post Reply