Help with mysql_query and INSERT INTO
| From: | Colin Davis | Date: | Sat, 04 Feb 2006 15:22:23 +0000 |
| Subject: | Help with mysql_query and INSERT INTO | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-229891@lists.php.net to get a copy of this message | ||
I need to insert a new record into a MySQL table which has an auto_increment
field Ref as the primary index. When I have inserted the new record, I need
to get the new Ref value in order to name some files to relate to the
record. At the moment I have to do a SELECT command and search for another
field (Title) which might not be unique.
Is there another way that I get the Ref back after an INSERT?
When I use mysql_query with INSERT INTO it only returns true or false,
rather than the row. The PHP manual says:
Return Values
For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a
resource on success, or FALSE on error.
For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query()
returns TRUE on success or FALSE on error.
Regards
Colin Davis