[英]Data not inserted but have no error PHP using bind_param
i have a simple code to input data to my database using prepare and bind_param 我有一个简单的代码,使用prepare和bind_param将数据输入到我的数据库
there is no error but my data are not inputted into database 没有错误,但我的数据没有输入数据库
$stmt1 = $mysqli -> prepare ("INSERT INTO equipment(eqp_type, eqp_name, eqp_qty, eqp_usd, $eqp_idr) VALUES (?,?,?,?,?)");
$stmt1->bind_param('sssss',$eqp_type, $eqp_name, $eqp_qty, $eqp_usd, eqp_idr);
$eqp_type = 'BUC';
$eqp_name = 'BUC test';
$eqp_qty = '1';
$eqp_usd = '0';
$eqp_idr = '0';
$stmt1->execute();
is there any idea why there is no error but my data are not inputted into database ? 有什么想法没有错误,但我的数据没有输入数据库?
You have to execute your query using 您必须使用执行查询
$stmt1->execute();
Read here: http://php.net/manual/en/pdostatement.execute.php 在这里阅读: http : //php.net/manual/en/pdostatement.execute.php
You might forget to execute it. 你可能忘了执行它。
You can do it with following code: 您可以使用以下代码执行此操作:
$stmt1->execute();
So your code would look as follows: 所以你的代码看起来如下:
$eqp_type = 'BUC';
$eqp_name = 'BUC test';
$eqp_qty = '1';
$eqp_usd = '0';
$eqp_idr = '0';
$stmt1 = $mysqli -> prepare ("INSERT INTO equipment(eqp_type, eqp_name, eqp_qty, eqp_usd, eqp_idr) VALUES (?,?,?,?,?)");
$stmt1->bind_param('sssss',$eqp_type, $eqp_name, $eqp_qty, $eqp_usd, $eqp_idr);
$stmt1->execute();
Manual 手册
你需要添加$stmt1->execute()
,你会得到错误,因为你也错过了eqp_idr
$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.