Re: what is wrong with this simple query?
| From: | Julie Meloni | Date: | Tue, 25 Jun 2002 02:19:44 +0000 |
| Subject: | Re: what is wrong with this simple query? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103716@lists.php.net to get a copy of this message | ||
PS> Here is my code...
PS> $query = "SELECT max(id) FROM bc_topic";
PS> $result = mysql_query($query);
PS> $temp = mysql_result($result, 0, "id"); <- this is line 8
PS> echo $temp[id];
PS> Here is the error I get ...
PS> Warning: id not found in MySQL result index 2 in /.../upload2.php on
PS> line 8
PS> What am I doing wrong here?
PS> I know for sure that there definately is a column named 'id' and it's
PS> the primary key and also an auto_increment.
You are not selecting id, you're selecting max(id). If you do not use
AS to make an alias, then you use max(id) as the third parameter of
mysql_result()
- Julie
--> Julie Meloni
--> julie@thickbook.com
--> www.thickbook.com
Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20