简体   繁体   English

插入不起作用我在做什么错?

[英]INSERT INTO not working what am i doing wrong?

This script will not insert into my db table and i dont know why!!!! 该脚本不会插入到我的数据库表中,我也不知道为什么! HELP I get no errors on the page just simply does not update in my bd 帮助我在页面上没有错误,只是我的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')");

You're using a reserved word => to in 您正在使用保留字=> to输入

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

Consult the following for a list of reserved words: 请查阅以下内容以获取保留字列表:
- http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html -http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

Escape it by wrapping it in backticks 通过将其包装在反引号中进行转义

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

or choose another word. 或选择另一个单词。

Do check errors with or die(mysqli_error($con)) or die(mysqli_error($con))检查错误or die(mysqli_error($con))

including 包含

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

at the top of your files. 在文件顶部。

Reference links: 参考链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM