RE: [PHP-DB] mysql_insert_id
| From: | Sam Masiello | Date: | Wed, 05 Jul 2000 17:14:37 +0000 |
| Subject: | RE: [PHP-DB] mysql_insert_id | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-879@lists.php.net to get a copy of this message | ||
Try using mysql_insert_id($result). As it is now, you are doing
mysql_insert_id() on your SQL statement itself when you should be doing it
on the result set.
Sam Masiello
System Analyst
Chek.Com
(716) 853-1362 x289
smasiello@chekinc.com
-----Original Message-----
From: Greg Donald [mailto:webmaster@destiney.com]
Sent: Wednesday, July 05, 2000 1:10 PM
To: php-db@lists.php.net
Subject: [PHP-DB] mysql_insert_id
I upgraded from PHP 3.0.16 to 4.0.1pl2. Some of my code is broken now and I
don't see why.
$sql = "INSERT INTO categories (Category) VALUES ('$CategoryName')";
$result = mysql_query($sql);
$new_id = mysql_insert_id($sql);
This code now produces this error:
Warning: Supplied argument is not a valid MySQL-Link resource
Not to mention the $new_id is null.
Seems the rules for mysql_insert_id have changed or something. I looked in
the manual but I don't see what is wrong...
This same error is happening consistently everywhere I have used the
mysql_insert_id function. Anyone know why or what I need to do to fix it?
Thanks,
Greg
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net