checkUnique function?
Hey, so I have created a function to check the DB for unique entries, but when I call the function it doesn't seem to work and gives me a fatal error any ideas from the function or do you wish to see the sign up page calling it. Thanks :)
开发者_开发知识库 //Check for unique entries
function checkUnique($table, $field, $compared)
{
$query = $mysqli->query('SELECT '.$mysqli->real_escape_string($field).' FROM '.$mysqli->real_escape_string($table).' WHERE "'.$mysqli->real_escape_string($field).'" = "'.$mysqli->real_escape_string($compared).'"');
if(!$query){
return TRUE;
}
else {
return FALSE;
}
}
The page calling it.....
if (!empty($_POST['username']) && !empty($_POST['password']) && $_POST['password']==$_POST['password_confirm'] && !empty($_POST['email']) && validateEmail($_POST['email']) == TRUE && checkUnqiue('users', 'email', $_POST['email']) == TRUE && checkUnique('users', 'username', $_POST['username']) == TRUE)
Erorr....
Fatal error: Call to undefined function checkunqiue() in /home/mbattles/public_html/home/signup.php on line 17
checkUnqiue
is not checkUnique
Have you checked that the double quotes you are using are not causing the problems?
For example, the bit that says:
' WHERE "'.$mysqli->real_escape_string($field).'" = "'
Changing it to:
' WHERE '.$mysqli->real_escape_string($field).' = "'
work for you?
( or what Arkh just posted ;)
"undefined function checkunqiue()"
Check your spelling of the function name
精彩评论