Problem with Select Max

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Problem with Select Max

Post by wizzard »

$msql = "SELECT MAX(pn_uid) from nuke_users";
$result = mysql_query($msql);
$maxid = mysql_result($result, 0, "pn_uid");

=> i got this error:

Warning: pn_uid not found in MySQL result index 2 in /usr/local/psa/home/vhosts/xxxxxxxxxx/httpdocs/test/test.php on line 8

Don't know whats wrong with it.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

try aliasing the MAX(column) and calling the alias ie:

Code: Select all

$msql = "SELECT MAX(pn_uid) AS uid_alias from nuke_users"; 
$result = mysql_query($msql); 
$maxid = mysql_result($result, 0, "uid_alias");
Post Reply