ERROR: 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 '1' at line 1
MySQL/SQL/PHP 구문 오류
양식 제출시 위의 오류가 발생합니다.
폼 (HTML) :
<form action="register.php" method="POST">
<input type="text" name="username" maxlength="25" class="txtbx" placeholder="Username"><br>
<input type="password" name="password" maxlength="40" class="txtbx" placeholder="Password"><br>
<input type="password" name="confirm_password" maxlength="40" class="txtbx" placeholder="Confirm Password"><br>
<input type="text" name="email" maxlength="50" class="txtbx" placeholder="Email"><br>
<input type="text" name="confirm_email" maxlength="50" class="txtbx" placeholder="Confirm Email"><br>
<input type="submit">
</form>
PHP의 :
$connect=mysqli_connect("[host (snip)]", "[username (snip)]", "[password (snip)", "[database name (snip)]");
if (mysqli_connect_errno())
{
echo "<script>alert('Error connecting to MySQL:' . mysqli_connect_error())</script>";
}
$username=mysqli_real_escape_string($connect, $_POST['username']);
$password=mysqli_real_escape_string($connect, $_POST['password']);
$password2=mysqli_real_escape_string($connect, $_POST['confirm_password']);
$email=mysqli_real_escape_string($connect, $_POST['email']);
$email2=mysqli_real_escape_string($connect, $_POST['confirm_email']);
if($password!=$password2)
{
echo "<script>alert('The password and the password confirmation do not match.');</script>";
}
if($email!=$email2)
{
echo "<script>alert('The email and the email confirmation do not match.');</script>";
}
if($username && $password == $password2 && $email == $email2)
{
$addto=mysqli_query($connect,"INSERT INTO users (username, password, email)
VALUES ('$username', '$password', '$email')");
if (!mysqli_query($connect,$addto))
{
die('ERROR: ' . mysqli_error($connect));
}
else
{
echo "Successful!";
}
}
mysqli_close($connect);
나는이 오류를 이해하지 않습니다. PHP 코드의 첫 번째 줄에는 문자 '1'이 없습니다. mysqli
대신 mysql
이되어야하나요? 코멘트에서 언급 한 바와 같이
감사합니다, ~ 동음
이 줄은'이해가되지 않는 경우 ($ 사용자 이름 && $ 암호 == $ 암호 2 && $ 이메일 == $ EMAIL2)' –
게다가, 당신은 두 번'mysqli_query' 사용하고는.'변경하는 경우 (! mysqli_query ($ 연결, $의 addto) (! $의 addto) 프레드-II-라인 @' –
당신이 아무튼 말한다면'에)' 'T는 말이 아마과 같이 기록 할 것으로 예상되는합니다 '경우 ($ 사용자 이름 && ($ 암호 == $ 암호 2) && ($ 이메일 == $ EMAIL2)) $ 사용자 이름은 제로에 대한 확인되고있다',/0이 아닌 값 –