Ben sitemde bir kayıt / giriş sistemi var ve birileri zaten kullanımda olan bir kullanıcı adı ile kaydolmak için çalışırsa, o forma altında bir hata nakleder ki bunu yaptık. Bunun yerine oluşturulan hata mesajı gönderme Ancak, bir MySQL hata "Hata: Sorgu boştu" döndürür. İşte ben bunu yapmak için kullanmaya çalışıyorum kodu:
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM userpass WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
$error = "Sorry, the username ".$_POST['username']." is already in use.";
}
Ben yanlış ne yapıyorum?
Teşekkürler