views:

54

answers:

3

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
+3  A: 

checkUnqiue is not checkUnique

Arkh
ahah very good, stupid typo's.
Chris Leah
Ah, typo-overflow errors...
David Thomas
+1  A: 

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 ;)

zaf
A: 

"undefined function checkunqiue()"

Check your spelling of the function name

RDL