Jump to content

Mysql Query to select * except for 1.


duckxtales

Recommended Posts

I have the following code and I'm having trouble doing a query where it looks up the DB to see if the email exsist, but it should bypass a specific email. Is there an except syntax where I can use to do a query to select * where email = $email except where email = '[email protected]'; ?

 

$results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email'");

$duplicatex = mysql_num_rows($results);

$duplicatexArray = mysql_fetch_array($results);

$atsign = substr_count($Email, '@');

 

if($duplicatex > 1) die("ERROR, MORE THAN 1 EMAIL HAS BEEN DETECTED. PLEASE REPORT TO ADMIN.");

Link to comment
https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/
Share on other sites

As you set the value of $email that goes into the query then simply do not set it to the email you wish to be ignored by the query. If this is a user entering an email address to check if its listed then

 

$results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email' AND email != '[email protected]'");

 

Will ensure that no results are returned...

 

Or you could save yourself a query and do this..

 

if (strcasecmp('[email protected]', $email) == 0)
{
echo "NO RESULTS";
}
else
{
$results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email'");
$duplicatex = mysql_num_rows($results);
$duplicatexArray = mysql_fetch_array($results);
$atsign = substr_count($Email, '@');

if($duplicatex > 1) die("ERROR, MORE THAN 1 EMAIL HAS BEEN DETECTED. PLEASE REPORT TO ADMIN.");
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.