如何用php将对象信息注册到mysql数据库中

如何用php将对象信息注册到mysql数据库中,php,mysql,Php,Mysql,我在这里要做的是在我的数据库中注册一些对象定位数据。我试图用这个URL发送对象数据,但它不起作用 启用错误报告,查看是否有错误。请。它们不再得到维护,而是在使用。改为了解,并使用。在$sql查询中,对数据库、表名和字段名使用反勾号。使用单引号。另外,正如Jay所说,您需要使用PDO <?php //db information $db = "test"; $dbu = "user"; $dbp = "pass"; $host = "localhost"; //connect $db

我在这里要做的是在我的数据库中注册一些对象定位数据。我试图用这个URL发送对象数据,但它不起作用



启用错误报告,查看是否有错误。请。它们不再得到维护,而是在使用。改为了解,并使用。在$sql查询中,对数据库、表名和字段名使用反勾号。使用单引号。另外,正如Jay所说,您需要使用PDO
<?php  

//db information
$db = "test";
$dbu = "user";
$dbp = "pass";
$host = "localhost";
//connect
$dblink = mysql_connect($host,$dbu,$dbp);
$seldb = mysql_select_db($db);

//I belive the problem is here
if(isset($_GET['id']) && isset($_GET['px']) && isset($_GET['py']) && isset($_GET['stats']) &&isset($_GET['frame'])){


     $id = strip_tags(mysql_real_escape_string($_GET['id']));
     $px = strip_tags(mysql_real_escape_string($_GET['px']));
     $py = strip_tags(mysql_real_escape_string($_GET['py']));
     $stats = strip_tags(mysql_real_escape_string($_GET['stats']));
     $frame = strip_tags(mysql_real_escape_string($_GET['frame']));


     $sql = mysql_query("INSERT INTO `$db`.`building` (`id`,`px`,`py`, `stats`,`frame`) VALUES ('$id','$px','$py','$stats','$frame');");

     if($sql){


          echo 'success';

     }else{


          echo 'fail';

     }

}else{
     echo 'variable not set';
}

mysql_close($dblink);//Close off the MySQL connection.
?>