Re: mysql_insert_id()
| From: | Zeev Suraski | Date: | Fri, 01 Sep 2000 12:34:12 +0000 |
| Subject: | Re: mysql_insert_id() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2557@lists.php.net to get a copy of this message | ||
It can't work right anywhere, because mysql_insert_id() receives a mysql
link as an argument, and not a result set. If you have the mysql link
handle available, provide it to mysql_insert_id(), or simply call
mysql_insert_id() with no arguments.
Zeev
On Fri, 1 Sep 2000, Fam de Boer wrote:
> Hello,
>
> The following snippet:
> --------------------
> $result = mysql_db_query($db, "insert into klant values (null, '$naam',
> '$bedrijfsnaam', '$adres', '$postcode', '$woonplaats',
> '$telefoonnummer',
> '$email', '$ww')");
>
> if (!$result)
> { echo(mysql_errno(), mysql_error());
> return;
> }
>
> $klant_id = mysql_insert_id($result);
> echo("<<$klant_id>>");
> --------------------
>
> It gives an error saying:
> Warning: Supplied argument is not a valid MySQL-Link resource in
> /opt/guide/www.moc-bedrijfskleding.nl/HTML/beta/order_newcustomer_finalize.p
> hp3 on line 70
> line 70 is the line:
> $klant_id = mysql_insert_id($result);
>
> It worked fine with netscape & php3 on my linux programming server.
> When I upload it to the it gives this error. I don't understand what goes
> wrong cause there is a $result and klant has an auto incrementing field:
> mysql> show fields from klant;
> +----------------+---------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +----------------+---------+------+-----+---------+----------------+
> | klant_id | int(11) | | PRI | 0 | auto_increment |
> | naam | text | YES | | NULL | |
> | bedrijfsnaam | text | YES | | NULL | |
> | adres | text | YES | | NULL | |
> | postcode | text | YES | | NULL | |
> | woonplaats | text | YES | | NULL | |
> | telefoonnummer | text | YES | | NULL | |
> | email | text | YES | | NULL | |
> | ww | text | YES | | NULL | |
> +----------------+---------+------+-----+---------+----------------+
>
> What goes wrong ?
>
> Kind regards,
> Joachim
>
>
>
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/