任何人都可以帮助我完成我的准备声明吗?准备好的声明
我无法弄清楚到底是怎么回事错在这里
$stmt = $dbCon->prepare("INSERT INTO rock_news (heading, subheading, description, author) VALUES (?, ?, ?, ?)");
$stmt->bind_param("sss", $heading, $subheading, $description, $author);
$stmt->execute();
// set parameters and execute
$heading = $_POST['heading'];
$subheading = $_POST['subheading'];
$description = $_POST['description'];
$author = $_POST['author'];
$stmt->execute();
这项工作?
$sql ="INSERT INTO rock_news (heading, subheading, description, author) VALUES ('$_POST[heading]','$_POST[subheading]','$_POST[description]','$_POST[author]')";
if ($dbCon->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $dbCon->error;
}
?>
我得到这个错误,同时试图连接
注意:未定义的常量标题的使用 - 在/xxx/sandbox/royalRockFestival/pages/send_form.php摆出“标题”第6行ssaddas警告: mysqli_stmt :: bind_param():类型定义字符串中的元素数量与第9行中的/xxx/sandbox/royalRockFestival/pages/send_form.php中绑定变量的数量不匹配
这是什么意思?
有什么代码之前'$语句= $ dbCon->准备(“INSERT INTO rock_news(标题,副标题,描述,作者)VALUES( ?,?,?,?)“);'? –
问题与$ stmt-> bind_param(“sss”,$标题,$副标题,$描述,$作者); 替换为$ stmt-> bind_param(“ssss”,$ heading,$ subheading,$ description,$ author); –