Page 1 of 1

Problem with Select Max

Posted: Thu Mar 13, 2003 6:25 am
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.

Posted: Thu Mar 13, 2003 7:41 am
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");