我在此上不断收到“致电会员”错误

时间:2019-04-11 16:35:04

标签: php

我正在尝试编写一个将用户注册到我的数据库中的函数。 但是我在不同的地方不断出现3个错误,说 前两次“在C:\中以布尔值调用成员函数fetch_assoc()”,并且 上一次“在C:\中以布尔值调用成员函数bind_param()” 在已加注星标的线上

function registerUser() {
$mysqli = new mysqli(DBHOST,DBUSER,DBPASS,DB);
if ($mysqli->connect_errno) {
error_log("Cannot connect to MySQL: " . $mysqli->connect_error);
return false;
}
$email = htmlspecialchars($mysqli->real_escape_string(strtolower($_POST['email'])));
//check for an existing user
$findUser = "SELECT id from Customer where email = '{$email}'";
$findResult = $mysqli->query($findUser);
$findRow = $findResult->fetch_assoc(); *****************
if (isset($findRow['id']) && $findRow['id'] != "") {
$_SESSION['error'][] = "A user with that e-mail address already exists";
return false;
}


$username = htmlspecialchars($mysqli->real_escape_string($_POST['username']));
//check for an existing user
$findUsername = "SELECT id from Customer where username = '{$username}'";
$findResultname = $mysqli->query($findUsername);
$findRowname = $findResultname->fetch_assoc(); ************
if (isset($findRowname['id']) && $findRowname['id'] != "") {
$_SESSION['error'][] = "A user with that username address already exists";
return false;
}

$lastName = htmlspecialchars($mysqli->real_escape_string($_POST['lastname']));
$firstName = htmlspecialchars($mysqli->real_escape_string($_POST['firstname']));
$cryptedPassword = crypt($_POST['password']);
$password = $mysqli->real_escape_string($cryptedPassword);
$city = htmlspecialchars($mysqli->real_escape_string($_POST['city']));
$state = htmlspecialchars($mysqli->real_escape_string($_POST['state']));
$phone = htmlspecialchars($mysqli->real_escape_string($_POST['phone']));
$gender = htmlspecialchars($mysqli->real_escape_string($_POST['gender']));

$query = "INSERT INTO items(username,first_name,last_name,email,phone,password,city,state,gender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("ssssissss", $username, $firstName, $lastName, $email, $phone, $password, $city, $state, $gender); **********
$result = $stmt->execute();
$mysqli->close();
return $result;
}

如何将当前日期时间保存到变量中 另外,是否将日期时间函数绑定为字符串?

说实话,即时通讯仍在学习中,如果有人可以帮助我更正代码,我将非常感谢。甚至包括现在的时间

0 个答案:

没有答案