INSERT INTO不工作我做错了什么?

时间:2014-08-14 18:16:27

标签: php mysql insert

这个脚本不会插入到我的db表中,我也不知道为什么!!!!救命 我在页面上没有错误只是在我的bd中没有更新

$con = new mysqli("***","*****","******","****");

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$ponum=$con->real_escape_string($_POST['po']);
$date=$con->real_escape_string($_POST['date']);
$to=$con->real_escape_string($_POST['to']);
$time=$con->real_escape_string($_POST['time']);
$vin=$con->real_escape_string($_POST['stk_vin']);
$reason=$con->real_escape_string($_POST['reason']);
$amount=$con->real_escape_string($_POST['amount']);
$empnum=$con->real_escape_string($_POST['emp']);
$manange$con->real_escape_string(r=$_POST['mananger']);
$accnum=$con->real_escape_string($_POST['acc']);
$store_location=$con->real_escape_string($_POST['store']);
$borr=$con->real_escape_string($_POST['borrowed']);



mysqli_query($con,"INSERT INTO fpo(ponum,date,to,time,vin,reason,amount,empnum,mananger,accnum,
store_location,borr)
VALUES ('$ponum','$date','$to','$time','$vin','$reason','$amount','$empnum','$mananger','$accnum','$store_location','$borr')");

1 个答案:

答案 0 :(得分:7)

您正在使用保留字=> to

INSERT INTO fpo (ponum,date,to,
                            ^^

请参阅以下内容以获取保留字列表:
  - http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

通过将其包裹在反引号中来逃避它

INSERT INTO fpo (ponum,date,`to`,

或选择其他字词。

请使用or die(mysqli_error($con))

检查错误

包括

error_reporting(E_ALL);
ini_set('display_errors', 1);

位于文件顶部。

参考链接: