Hello guys I have this php code to register building data in a game that I'm developing. This code work fine.
What I like to know is how can I echo the auto increased ID of the object that I registered using this code when the register function successful.
<?php
$db = "database";//Your database name
$dbu = "username";//Your database username
$dbp = "password";//Your database users' password
$host = "localhost";//MySQL server - usually localhost
$dblink = mysql_connect($host,$dbu,$dbp);
$seldb = mysql_select_db($db);
if(isset($_GET['oid']) ){
//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$name = strip_tags(mysql_real_escape_string($_GET['oid']));
$sql = mysql_query("INSERT INTO `$db`.`building` (`id`,`oid`) VALUES ('','$oid');");
if($sql){
//The query returned true echo the newly registered id
echo '????';
}else{
//The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
echo 'Fail to save data';
}
}else{
echo 'Fail-No object owner ID';
}
mysql_close($dblink);//Close off the MySQL connection to save resources.
?>
Please help me.