PHP mysqli致命错误:在布尔值上调用成员函数execute() [英] PHP mysqli Fatal error: Call to a member function execute() on boolean

查看:175
本文介绍了PHP mysqli致命错误:在布尔值上调用成员函数execute()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速提问.为什么会发生此错误?我找不到类型或任何内容. (我的代码虽然有点混乱)

Quick question. Why does this error occur? I can't find a type or anything. (my code is a bit messy though)

//Where i fill the names for the dropdown boxes
<select name="user_item_1_'.$user_item_box_id.'">
<select name="user_item_2_'.$user_item_box_id2.'">

//Fill the variables with the names
$trade_item_id_1_1 = $_POST['user_item_1_1'];
$trade_item_id_1_2 = $_POST['user_item_1_2'];
$trade_item_id_1_3 = $_POST['user_item_1_3'];
$trade_item_id_1_4 = $_POST['user_item_1_4'];

$trade_item_id_2_1 = $_POST['user_item_2_1'];
$trade_item_id_2_2 = $_POST['user_item_2_2'];
$trade_item_id_2_3 = $_POST['user_item_2_3'];
$trade_item_id_2_4 = $_POST['user_item_2_4'];

//Query
$query_insert_items = "INSERT INTO trade_item (item_id_1_1, item_id_1_2, item_id_1_3, item_id_1_4, item_id_2_1, item_id_2_2, item_id_2_3, item_id_2_4) VALUES (?,?,?,?,?,?,?,?)";
$stmt = $db->prepare($query_insert_trade);
$stmt->bind_param("iiiiiiii", $trade_item_id_1_1, $trade_item_id_1_2, $trade_item_id_1_3, $trade_item_id_1_4, $trade_item_id_2_1, $trade_item_id_2_2, $trade_item_id_2_3, $trade_item_id_2_4);
$stmt->execute();  

谢谢!

推荐答案

mysqli_prepare()返回语句对象,如果发生错误则返回FALSE.似乎准备失败,并为$stmt分配了布尔值.我推测由于未定义$query_insert_trade,准备失败.你可能是说

mysqli_prepare() returns a statement object or FALSE if an error occurred. Seems that prepare failed and assigned a boolean to $stmt. I speculate that prepare failed because $query_insert_trade isn't defined. You probably mean

$stmt = $db->prepare($query_insert_items);

这篇关于PHP mysqli致命错误:在布尔值上调用成员函数execute()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆