我試圖做一個登記制度,和我得到這個錯誤:PDO插入錯誤 - 執行(array());
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''=L&myPRwgOSB?V_execute(Array) #1 {main} thrown in /home/**/public_html/forum/register-cmd.php on line 58
,我不知道爲什麼。代碼如下:它有什麼問題?
<?php
include('./includes/connect.php');
/* START VARIABLES */
$submit = $_POST['submit'];
$username = clean($_POST['username']);
$email = clean($_POST['email']);
$repeatedemail = clean($_POST['remail']);
$password = clean($_POST['password']);
$repeatedpassword = clean($_POST['rpassword']);
$year = (int) $_POST['year'];
$day = (int) $_POST['day'];
$months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
if(in_array(ucwords($_POST['month']), $months)) {
$dob = $_POST['month'] . " " . $day . ", " . $year;
} else {
header('Location: register.php?error=nonexist');
}
$referrer = $_POST['referrer'];
$recieve_emails = (int) $_POST['getemail'];
$view_signatures = (int) $_POST['sig'];
/* END VARIABLES */
if(isset($username) && isset($submit) && isset($email) && isset($repeatedemail) && isset($password) && isset($repeatedpassword) && isset($year) && isset($day) && isset($_POST['month']) && isset($recieve_emails) && isset($view_signatures)) {
if($email == $repeatedemail) {
if($password == $repeatedpassword) {
$check_user = $con->prepare("SELECT * FROM users WHERE username = :username");
$check_user->execute(array(
":username" => $username
));
if($check_user->rowCount() == 1) {
header('Location: register.php?error=usernametaken');
} else {
$check_email = $con->prepare("SELECT * FROM users WHERE email = :email");
$check_email->execute(array(
":email" => $email
));
if($check_email->rowCount() == 1) {
header('Location: register.php?error=emailtaken');
} else {
$salt = salt();
$hashedPassword = sha1($pepper . $password . $salt);
$insert = $con->prepare("INSERT INTO users ('username', 'password', 'salt', 'email', 'dob', 'recieve_emails', 'view_signatures') VALUES (:username, :password, :salt, :email, :dob, :recieve_emails, :view_signatures)");
$insert->execute(array(
":username" => $username,
":password" => $hashedPassword,
":salt" => $salt,
":email" => $email,
":dob" => $dob,
":recieve_emails" => $recieve_emails,
":view_signatures" => $view_signatures
));
header('Location: index.php?success=registered');
exit();
}
}
} else {
header('Location: register.php?error=nomatchpassword');
}
} else {
header('Location: register.php?error=nomatchemail');
}
} else {
header('Location: index.php');
}
?>
哪些查詢是第58行? –
我不知道有多少完全相同的問題已被問到。 –
儘管如此,仍然以相同的熱情回答。對於這對夫妻來說,總有一個新來的新人渴望着。 –