Php 参数绑定不起作用的mysqli更新
我试图构建一个可重用的函数,用一条准备好的语句更新表中的一行。在翻阅了php.net文档之后,我想到了这个。我没有收到任何错误消息,但它没有更新表。(我编写了一个类似的函数来插入记录,效果很好。)希望我只是缺少了一些简单的东西,有人可以很容易地发现。:)Php 参数绑定不起作用的mysqli更新,php,mysql,mysqli,Php,Mysql,Mysqli,我试图构建一个可重用的函数,用一条准备好的语句更新表中的一行。在翻阅了php.net文档之后,我想到了这个。我没有收到任何错误消息,但它没有更新表。(我编写了一个类似的函数来插入记录,效果很好。)希望我只是缺少了一些简单的东西,有人可以很容易地发现。:) $\u POST被传递到$data,类似的数组('first\u name'=>'s','last\u name'=>'s'等)被传递到$fields 我做了一系列var_转储,看看发生了什么,这些就是结果 $params = array(17
$\u POST
被传递到$data
,类似的数组('first\u name'=>'s','last\u name'=>'s'等)
被传递到$fields
我做了一系列var_转储,看看发生了什么,这些就是结果
$params = array(17) {
[0]=> string(16) "ssidssdsdssssssi"
[1]=> &string(4) "asdf"
[2]=> &string(0) ""
[3]=> &string(1) "0"
[4]=> &string(4) "0.00"
[5]=> &string(0) ""
[6]=> &string(10) "0000-00-00"
[7]=> &string(4) "0.00"
[8]=> &string(10) "0000-00-00"
[9]=> &string(4) "0.00"
[10]=> &string(0) ""
[11]=> &string(0) ""
[12]=> &string(26) "bc__1412690490_384x523.jpg"
[13]=> &string(0) ""
[14]=> &string(0) ""
[15]=> &string(0) ""
[16]=> &int(2)
}
$fields = array(15) {
["edition"]=> string(1) "s"
["ISBN"]=> string(1) "s"
["pages"]=> string(1) "i"
["price"]=> string(1) "d"
["pub_year"]=> string(1) "s"
["release_date"]=> string(1) "s"
["pre_order_price"]=> string(1) "d"
["sale_start_date"]=> string(1) "s"
["sale_price"]=> string(1) "d"
["kindle"]=> string(1) "s"
["image_1"]=> string(1) "s"
["image_2"]=> string(1) "s"
["paypal_script"]=> string(1) "s"
["pre_order_paypal_script"]=> string(1) "s"
["sale_paypal_script"]=> string(1) "s"
}
$fieldnames = array(15) {
[0]=> string(7) "edition"
[1]=> string(4) "ISBN"
[2]=> string(5) "pages"
[3]=> string(5) "price"
[4]=> string(8) "pub_year"
[5]=> string(12) "release_date"
[6]=> string(15) "pre_order_price"
[7]=> string(15) "sale_start_date"
[8]=> string(10) "sale_price"
[9]=> string(6) "kindle"
[10]=> string(7) "image_1"
[11]=> string(7) "image_2"
[12]=> string(13) "paypal_script"
[13]=> string(23) "pre_order_paypal_script"
[14]=> string(18) "sale_paypal_script"
}
$query=string(232) "update editions set edition=?,ISBN=?,pages=?,price=?,pub_year=?,release_date=?,pre_order_price=?,sale_start_date=?,sale_price=?,kindle=?,image_1=?,image_2=?,paypal_script=?,pre_order_paypal_script=?,sale_paypal_script=? where id = ?"
$stmt = object(mysqli_stmt)#2 (10) { //(var_dump placed after $stmt->execute)
["affected_rows"]=> int(0),
["insert_id"]=> int(0),
["num_rows"]=> int(0),
["param_count"]=> int(16),
["field_count"]=> int(0),
["errno"]=> int(0),
["error"]=> string(0) "",
["error_list"]=> array(0) { },
["sqlstate"]=> string(5) "00000",
["id"]=> int(1)
}
运行此函数时,您可以发布SQL的外观吗?这是发送到$mysqli->prepare($query):$query=string(232)的查询字符串“更新版本集版本=?,ISBN=?,页面=?,价格=?,发布年份=?,发布日期=?,预订单价格=?,销售开始日期=?,销售价格=?,kindle=?,图像1=?,图像2=?,paypal脚本=?,预订单paypal脚本=?,销售paypal脚本=?”?其中id=?“在那之后,我不知道如何找出从stmt->bind_paramsolved返回的查询是什么样子的!我知道这一定是些愚蠢的事情,但我发布的任何东西都没有。我将错误的变量传递到id字段。没有传递id为的记录,因此我仍然不确定为什么没有看到某种错误;ini设置(“显示错误”,1)代码>在您的任何文件中?这可能就是它没有返回任何错误的原因。
$params = array(17) {
[0]=> string(16) "ssidssdsdssssssi"
[1]=> &string(4) "asdf"
[2]=> &string(0) ""
[3]=> &string(1) "0"
[4]=> &string(4) "0.00"
[5]=> &string(0) ""
[6]=> &string(10) "0000-00-00"
[7]=> &string(4) "0.00"
[8]=> &string(10) "0000-00-00"
[9]=> &string(4) "0.00"
[10]=> &string(0) ""
[11]=> &string(0) ""
[12]=> &string(26) "bc__1412690490_384x523.jpg"
[13]=> &string(0) ""
[14]=> &string(0) ""
[15]=> &string(0) ""
[16]=> &int(2)
}
$fields = array(15) {
["edition"]=> string(1) "s"
["ISBN"]=> string(1) "s"
["pages"]=> string(1) "i"
["price"]=> string(1) "d"
["pub_year"]=> string(1) "s"
["release_date"]=> string(1) "s"
["pre_order_price"]=> string(1) "d"
["sale_start_date"]=> string(1) "s"
["sale_price"]=> string(1) "d"
["kindle"]=> string(1) "s"
["image_1"]=> string(1) "s"
["image_2"]=> string(1) "s"
["paypal_script"]=> string(1) "s"
["pre_order_paypal_script"]=> string(1) "s"
["sale_paypal_script"]=> string(1) "s"
}
$fieldnames = array(15) {
[0]=> string(7) "edition"
[1]=> string(4) "ISBN"
[2]=> string(5) "pages"
[3]=> string(5) "price"
[4]=> string(8) "pub_year"
[5]=> string(12) "release_date"
[6]=> string(15) "pre_order_price"
[7]=> string(15) "sale_start_date"
[8]=> string(10) "sale_price"
[9]=> string(6) "kindle"
[10]=> string(7) "image_1"
[11]=> string(7) "image_2"
[12]=> string(13) "paypal_script"
[13]=> string(23) "pre_order_paypal_script"
[14]=> string(18) "sale_paypal_script"
}
$query=string(232) "update editions set edition=?,ISBN=?,pages=?,price=?,pub_year=?,release_date=?,pre_order_price=?,sale_start_date=?,sale_price=?,kindle=?,image_1=?,image_2=?,paypal_script=?,pre_order_paypal_script=?,sale_paypal_script=? where id = ?"
$stmt = object(mysqli_stmt)#2 (10) { //(var_dump placed after $stmt->execute)
["affected_rows"]=> int(0),
["insert_id"]=> int(0),
["num_rows"]=> int(0),
["param_count"]=> int(16),
["field_count"]=> int(0),
["errno"]=> int(0),
["error"]=> string(0) "",
["error_list"]=> array(0) { },
["sqlstate"]=> string(5) "00000",
["id"]=> int(1)
}