TylerRLD Posted April 20, 2013 Share Posted April 20, 2013 I currently have a php set up for a high-scores list. The mysql database has 3 fields. 1-id 2-Name 3-Score id is set to auto increment ive got it working to properly input name and score into the database and it automatically gives the entry an "id"... heres the code: $dbc = mysql_connect('ZShiscoreapp.db.10895904.hostedresource.com','username','password'); if (!$dbc) { die('Not Connected :' .mysql_error()); } $db_selected = mysql_select_db("ZShiscoreapp", $dbc); if (!$db_selected) { die("Cant Connect : " .mysql_error); } $pname=$_GET['nameinput']; $pscore=$_GET['scoreinput']; $query="INSERT INTO highs SET Score='$pscore', Name='$pname' "; $result=mysql_query($query); I want to get the assigned "id" from the database and print it. how can i do this? Link to comment https://forums.phpfreaks.com/topic/277170-database-return-id-from-input/ Share on other sites More sharing options...
trq Posted April 20, 2013 Share Posted April 20, 2013 mysql_insert_id. Link to comment https://forums.phpfreaks.com/topic/277170-database-return-id-from-input/#findComment-1425938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.