Questions tagged [mysql-insert-id]

Retrieves the ID from the previous INSERT query on this database connection.

mysql_insert_id() is used to retrieve the ID from a previous INSERT query on this database connection.

The query must have been made to a table that has an auto_increment field - that is the field that will be returned.

You can pass in an optional parameter, which is the database connection to use; otherwise it will use the most recently opened database connection as a default.

Note that this function is connection-based - two separate processes invoking this function separately will create two separate connections to the database, which means that each process will return the correct ID for its own insert.

Note that as of PHP 5.5.0, this function has been deprecated.

124 questions
-2
votes
2 answers

Inserting in MySQL with PHP large amount of rows and autoincrementation ID

I have about 50k entries that I am inserting in MySQL via PHP. Table is simple with ID (autoincrementation), and few VARCHAR fields... Since this system allows multiple users to login at same time and do the same operation of inserting data, so…
Peter
  • 1,264
  • 5
  • 20
  • 41
-3
votes
1 answer

question about execute PHP file, from other php file on the same folder

i download 2 php file, one is index. php for input form, and other is insert.php. i have put them on the same folder. when i click submit it execute insert.php file it work fine and it insert form data into my database. but the question is: how it…
musab
  • 37
  • 6
-3
votes
3 answers

INSERT INTO not working for 2nd table

I'm new to PHP but normally able to solve most problems but this one has got me. I'm trying to create a newsletter sign up (single field) with a single submit button. I have this working fine, sending out an email and inserting the form data into my…
Rich
  • 1
  • 4
-3
votes
1 answer

mysql_insert_id() always returning 0

I have this code that I need to populate through a form a new line in two tables with a foreign key constrain. This doe refer to the first insert only, and I need identify the last_id generated to use it for the related table. But $last_id returns…
Velectro
  • 11
  • 3
1 2 3
8
9