Re: [PHP] manual key generation

From: Ewout De Boer (ewout_at_chemistry-interactive.nl)
Date: 10/26/03


To: "PHP General" <php-general@lists.php.net>
Date: Sun, 26 Oct 2003 00:49:14 +0200


----- Original Message -----
From: "Joao Andrade" <joao66br@yahoo.com.br>
To: <php-general@lists.php.net>
Sent: Sunday, October 26, 2003 12:31 AM
Subject: [PHP] manual key generation

>
> Aloha!
>
> I have a script that inserts a new row in a table called "quotations",
> which has a primary key called "quotation_id". "quotation_id" is an
int(11)
> type. When I enter:
>
> SELECT MAX(quotation_id)+1 from quotations
>
> I get simply the number 7 (which is ok)
>
> But when I do:
>
> $new_key = mysql_query("SELECT MAX(quotation_id)+1 from quotations")
>
> I get $new_key = Resource id #3
>
> What the hell is that supposed to mean?

As the error-text says... mysql_query returns a result id

use this code instead:

$mri = mysql_query("SELECT MAX(quotation_id)+1 from quotations");
$result = mysql_fetch_row($mri);
$new_key = $result[0];

see the php.net website for details !

// Ewout



Relevant Pages

  • Howards New Web Site. SLOW AS HELL
    ... I can see the new site is programmed in PHP, not sure what the old one was. ... The old site was nice and fast, while this new one is slow as hell. ... have moved to a new server. ... Web site is useless right now. ...
    (alt.fan.howard-stern)
  • Re: Howards New Web Site. SLOW AS HELL
    ... slow as hell. ... I'm a PHP programmer, so it's not the PHP that's slowing it down. ... logical reason is that the old server didn't supposed PHP, ...
    (alt.fan.howard-stern)
  • Re: Howards New Web Site. SLOW AS HELL
    ... slow as hell. ... I'm a PHP programmer, so it's not the PHP that's slowing it down. ... logical reason is that the old server didn't supposed PHP, ...
    (alt.fan.howard-stern)
  • Re: how to check whether the page is the last page?
    ... Rob wrote: ... Besides, even if Jerry and I were the two worst people on earth, what the hell would that have to do with PHP? ...
    (comp.lang.php)