quick question on max()

From: Date: Wed, 11 Apr 2001 14:16:52 +0000
Subject: quick question on max()
Groups: php.db 
Request: Send a blank email to php-db+get-8486@lists.php.net to get a copy of this message
Can you use max within a select function? This is where I have it...
    $cd_qry = 'select max(code) from equipment';
    connecttodb();
      $result = mysql_query($cd_qry);
      $temp = mysql_fetch_row($result);
      $bcode = $BCODE_START . str_pad((substr($temp[0], -6) + 1),6,'0',STR_PAD_LEFT);
However, I'm getting an error that says "Supplied argument is not a valid MySQL result resource in /usr/local/nusphere/apache/htdocs/ese-lab/Protect/add.php3 on line 162". The line beginning with $temp is line 162... would this be why? I'm using MySQL 3.23.33 and PHP 4.0.4 . Thanks, Liz

« previous php.db (#8486) next »