This question already has answers here:
Fatal error: Call to a member function bind_param() on boolean
                                
                                    (12个答案)
                                
                        
                                2年前关闭。
            
                    
我有以下代码:

echo "debug 12.1";
$stmmt21 = $conn->prepare("INSERT INTO Together (OneT, TwoT) VALUES (?, ?)");
$UserOne = "netsgets";
$UserTwo = "netsgets2";
$stmmt21->bind_param('ss', $UserOne, $UserTwo);
$UserOne = "netsgets";
$UserTwo = "netsgets2";
$stmmt21->execute();
$stmmt21->store_result();


当我运行它时,出现此错误:


  在布尔值上调用成员函数bind_param()

最佳答案

这是因为您的语句$conn->prepare(...导致了某种错误,该错误肯定会将false分配给$stmmt21。因此,当您在bind_param(...上调用$stmmt21时,解析器会抱怨它在boolean上不允许使用。

解决方案:请检查为什么$conn->prepare()给您错误。是由于您的连接字符串还是您指定的INSERT查询。

关于php - 在插入数据(PHP)中的 bool 值上调用成员函数bind_param(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46679755/

10-13 02:05