知道这里发生了什么吗?
$stmt = $con->prepare("INSERT INTO `users` (`FirstName`, `LastName`, `Email`, `Password`, `DateOf_Birth`, `DateOf_Create`, `Gender`, `City`, `Country`, `Status`, `Validation`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) LIMIT 1");
$stmt->bind_param('ssssiisssis', $Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);
每个列和表的名称都是正确的,我现在多次检查它。那有什么不对吗?
我收到此错误代码:PHP致命错误:在布尔值上调用成员函数bind_param()
答案 0 :(得分:0)
LIMIT 不会进行插入查询,因为insert只会执行一次。如果你想多次执行它,你需要一个循环(while,for,foreach)。所以你必须删除“LIMIT 1”。
检查此行(签名错误``和包含LIMIT):
$stmt = $con->prepare("INSERT INTO `users` (`FirstName`, `LastName`, `Email`, `Password`, `DateOf_Birth`, `DateOf_Create`, `Gender`, `City`, `Country`, `Status`, `Validation`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) LIMIT 1");
必须是这种方式(标志固定''没有LIMIT):
$stmt = $con->prepare("INSERT INTO 'users' ('FirstName', 'LastName', 'Email', 'Password', 'DateOf_Birth', 'DateOf_Create', 'Gender', 'City', 'Country', 'Status', 'Validation') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
检查这一行(12个参数,但只有11个在你的sql中绑定):
$stmt->bind_param('ssssiisssis', $Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);
必须这样(固定11个参数= $ sql上的11个值):
$stmt->bind_param($Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);
您也必须检查一下:
A)您的字符串连接$con
,以确保您拥有正确的值。检查您是否真正连接到mysqli
B)表名和列名是正确的,看它们是否有任何拼写错误(因为错误与布尔值有关)