当我尝试在我的应用程序中注册时出现错误,我得到这个错误:致命错误:在第36行调用C:... \ signup.php中的成员函数bind_param()
如果您想知道,我在我的ios应用程序中使用Http Request!
出了什么问题?
thnxs
php代码
<?php
// Xx_mr.drama_xX
header('Content-type: application/json');
if($_POST) {
$username =mysql_real_escape_string($_POST['username']);
$email =mysql_real_escape_string( $_POST['email']);
$password =mysql_real_escape_string( $_POST['password']);
$phonenumper =($_POST['phonenumper']);
if($_POST['username']) {
if ( $password <=6 or $password >=32 ) {
$db_name = 'posting';
$db_user = 'root';
$db_password = 'root';
$server_url = 'localhost';
$mysqli = new mysqli('localhost', $db_user, $db_password, $db_name);
/* check connection */
if (mysqli_connect_errno()) {
error_log("Connect failed: " . mysqli_connect_error());
echo '{"success":0,"error_message":"' . mysqli_connect_error() . '"}';
} else {
//$stmt = $mysqli->prepare("INSERT INTO users (username, email, password , phonenumper)
// VALUES ( '$username' , '$email' , '$password' , '$phonenumper')";
$stmt = mysqli_prepare($mysqli, "INSERT INTO users VALUES (?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'sssd', $username, $email, $password, $phonenumper);
//"INSERT INTO `users`(`username`, `password`) VALUES ('".$username."', '".$password."')";
$password = md5($password);
$stmt->bind_param('sssd', $username, $password,$email,$phonenumper);
/* execute prepared statement */
$stmt->execute();
if ($stmt->error) {error_log("Error: " . $stmt->error); }
$success = $stmt->affected_rows;
/* close statement and connection */
$stmt->close();
/* close connection */
$mysqli->close();
error_log("Success: $success");
if ($success > 0) {
error_log("User '$username' created.");
echo '{"success":1}';
} else {
echo '{"success":0,"error_message":"Username Exist."}';
}
}
} else {
echo '{"success":0,"error_message":"Password does not match."}';
}
} else {
echo '{"success":0,"error_message":"Invalid Username."}';
}
}else {
echo '{"success":0,"error_message":"Invalid Data."}';
}
?>