插入查询不插入错误消息

时间:2013-07-26 22:37:59

标签: php mysql

我无法在db中获取对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

1 个答案:

答案 0 :(得分:0)

试试这个

    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));