affordit Posted January 31, 2008 Share Posted January 31, 2008 I am wanting to use the below code to check table to find out if name OR email address already exists but I get an error. Says syntax error near FROM test Where name = '$name' || email = '$email'"; Here is all of the code: $query = "Select name, email, from test Where name = '$name' || email = '$email'"; $results = mysql_query($query) or die(mysql_error()."<br /><br />".$query); $num=mysql_numrows($results); if ($name == name) { print "Name exists"; exit(); }elseif ($email == email){ print "Email exists"; exit(); Quote Link to comment https://forums.phpfreaks.com/topic/88798-select-query-problem/ Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 This might be useful, it's a checkunique function I use function checkUnique($table, $field, $compared){ if (get_magic_quotes_gpc()) { $table = stripslashes($table); $field = stripslashes($field); $compared = stripslashes($compared); } $table = mysql_real_escape_string($table); $field = mysql_real_escape_string($field); $compared = mysql_real_escape_string($compared); $result = mysql_query("SELECT $field FROM $table WHERE $field = '$compared'"); if(mysql_num_rows($result)==0) { return TRUE; } else { return FALSE; } } Quote Link to comment https://forums.phpfreaks.com/topic/88798-select-query-problem/#findComment-454790 Share on other sites More sharing options...
affordit Posted January 31, 2008 Author Share Posted January 31, 2008 I have no clue what to do with what you just posted??? Quote Link to comment https://forums.phpfreaks.com/topic/88798-select-query-problem/#findComment-454796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.