这个问题在这里已经有答案了:
致命错误:对非对象调用成员函数close()。mysqli问题(3个答案)
两年前关门了。
错误:
致命错误:未捕获错误:对c:\xampp\htdocs\project\script\register中的布尔值调用成员函数close()。php:69
堆栈跟踪:#0 c:\xampp\htdocs\project\index.php(2):include#once()#1{main}在c:\xampp\htdocs\project\script\register.php的第69行抛出
当我传递通过验证的正确数据时出错。
文件:
<?php
include_once 'functions.php';
include_once 'dbconnect.php';
// Returns the request method used to access the page
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$err="";
// Validation ....
.....
// End of it
$prep_stmt = "SELECT id FROM members WHERE email = ? LIMIT 1";
$stmt = $sql_db->prepare($prep_stmt);
// check existing email
if ($stmt) {
$stmt->bind_param('s', $email);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 1) {
// A user with this email address already exists
$err .= '<p class="error">A user with this email address already exists.</p>';
$stmt->close();
}
} else {
$err .= '<p class="error">Database error Line 39</p>';
$stmt->close();
}
// check existing username
$prep_stmt = "SELECT id FROM members WHERE username = ? LIMIT 1";
$stmt = $sql_db->prepare($prep_stmt);
if ($stmt) {
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 1) {
// A user with this username already exists
$err .= '<p class="error">A user with this username already exists</p>';
$stmt->close();
}
} else {
$err .= '<p class="error">Database error line 55</p>';
$stmt->close();
}
// Hashing, salting and inserting the values.
....
// End of file.
寻找答案为什么有问题却什么也没找到。
另一个类似这样的线程$stmt->close()位于if函数中。
1条答案
按热度按时间kxeu7u2r1#