gpt4 book ai didi

php - 插入查询不插入没有错误信息

转载 作者:行者123 更新时间:2023-11-30 23:15:53 25 4
gpt4 key购买 nike

我无法在数据库中获取 INSERT 的 INSERT 查询。我没有收到任何错误消息,并且正在学习教程,我们将不胜感激任何帮助。

$query = "INSERT INTO rooms (room_title,room_description,monthly_rate,prop_name,prop_description) VALUES ( ?, ?, ?, ?, ?)";

$stmt = mysqli_prepare($dbc,$query);
//$stmt = mysqli_query($dbc, $query);
if($stmt == false) {
die("<pre>".mysqli_error($dbc).PHP_EOL.$query."</pre>");
}

mysqli_stmt_bind_param($stmt,"ssiss",$pn,$d,$p,$ppn,$ppd);
mysqli_stmt_execute($stmt);
//mysqli_stmt_close($stmt);
// Check the results...
if (mysqli_stmt_affected_rows($stmt) == 1)

{

echo'<p>The room has been added.</p>';
// Clear $_POST:
$_POST = array();

}

mysqli_stmt_close($stmt);

} // End of $errors IF.
// End of the submission IF.

因为它没有回显“房间已添加”我怀疑问题出在 mysqli_stmt_affected_rows($stmt) == 1

最佳答案

试试这个

    if ($stmt = mysqli_prepare($dbc, "INSERT INTO rooms (room_title,room_description,monthly_rate,prop_name,prop_description) VALUES ( ?, ?, ?, ?, ?)")) {

mysqli_stmt_bind_param("ssiss",$pn,$d,$p,$ppn,$ppd);

mysqli_stmt_execute($stmt);

} printf("Error: %s.\n", mysqli_stmt_error($stmt));

关于php - 插入查询不插入没有错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17892103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com