Getting row data of inserted row (Mysql, PHP, mysqli)?

If so you can use mysql_insert_id() or mysqli->insert_id to get that value, and then use it to select the row More info here.

If so you can use mysql_insert_id() or mysqli->insert_id to get that value, and then use it to select the row. More info here.

Or you can write a query to get the id yourself and then put it in the inserted data. – Arthur Thomas Dec 18 '09 at 17:06 Arthur: That's true, but there's always a chance that another client will be trying to do the same thing at the same time and you'll end up with a collision. – Jordan Dec 18 '09 at 17:13 Jordan: Thank you very much, works perfect.

I had seen this method, but did understand know how worked. TY! – Douglas Dec 18 '09 at 17:40 Jordan: If the query is SELECT LAST_INSERT_ID() then it's safe.

The value is stored/returned per session. – VolkerK Dec 18 '09 at 18:35 Jordan: I do not use mysql so I am not sure but hopefully it doesn't work like that. The postgresql serial (autonumber) ensures each number is unique no matter what.

But I dunno about mysql :) – Arthur Thomas Dec 18 '09 at 18:35.

I need to get back the postid (auto-incrementing PK) of a row when I insert it. Where $title is the title name of the newly-inserted post. Is there part of the mysqli class that will allow me to do this in one query?

Does $db -> query() return any information that will make this simpler and more secure?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions