1

Is there a straightforward way to run mysql_query with an insert and get the ID of the new row, for example in the return? Or will I have to do another query with select to check it?

Dana
  • 32,083
  • 17
  • 62
  • 73
fmsf
  • 36,317
  • 49
  • 147
  • 195

3 Answers3

7

mysql_insert_id()

or

select last_insert_id()

2

Simply call mysql_insert_id after running mysql_query and you will get the ID.

Noah Goodrich
  • 24,875
  • 14
  • 66
  • 96
2

Try mysql_insert _id()

soulmerge
  • 73,842
  • 19
  • 118
  • 155