Jump to content

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 = 'xxx@xx.com'; ?

 

$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 != 'xx@xx.xom'");

 

Will ensure that no results are returned...

 

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

 

if (strcasecmp('xx@xx.com', $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.");
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.