php - Get last ID after SQL insert -


Below this code, some data is included in a MySQL database. After inserting the page is loaded on this record , But the variable ($ insertion) I'm trying to load is at the top. Can anyone help?

  $ pdo = Database :: connect (); $ Pdo- & gt; Set Attribution (PDO :: ATTRRAMOD, PDO :: ERMMDMEXEPEPS); $ Sql ​​= "Rider (first name, second name, email, mobile, landline, dub, adressline 1, city, county, postcode) values ​​(?,?,?,?,?,?,?,?,?,?,?, ?) "; $ Q = $ pdo- & gt; Ready ($ sql); $ Q- & gt; Execute (array ($ firstname, $ secondname, $ email, $ mobile, $ landline, $ birth date, $ streetaddress, $ city, $ county, $ postcode)); $ Insert = mysql_insert_id (); Database :: Disconnect (); Header ("Place: .add.php ID = $ insert"); Use  $ pdo->    

LastInsertId () is getting the last id after inserting SQL.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -