Jump to content

DB


shage

Recommended Posts

			$query = "INSERT INTO ".MYSQL_TBL_MAILLIST_BLACKLIST." VALUES ('$email')";
                        $query = "DELETE FROM ".MYSQL_TBL_MAILLIST_SUBSCRIBERS." WHERE address = '$email' AND userkey = '$key'";
		$result = mysql_query($query) or die("Query failed : " . mysql_error());

 

why is it not adding the email addresse that is pulled to the db,hmmm

Link to comment
Share on other sites

Well the problem is only the last query is being run. The first query will never be run as the second query is overriding it as you are reassigning the $query variable a new value - which is the second query.

 

In order for SQL queries to be ran you must run them with the mysql_query function. Just defining the query within a variable on it's own wont do anything as PHP sees the $query variable holding a string. PHP wont see it as an MySQL query and run that query through MySQL.

 

This is what your code should be:

<?php

// run the first query which inserts the email addy into the blacklist
$query1 = "INSERT INTO ".MYSQL_TBL_MAILLIST_BLACKLIST." VALUES ('$email')";
$result1 = mysql_query($query1) or die("Query1 failed : " . mysql_error());

// now we ckeck to see if the query ran successfully
// if it did we'll run the second query
if($result1)
{
    $query2 = "DELETE FROM ".MYSQL_TBL_MAILLIST_SUBSCRIBERS." WHERE address = '$email' AND userkey = '$key'";
    $result2 = mysql_query($query) or die("Query2 failed : " . mysql_error());

   // rest of code here
}
else
{
    // do something else
}

?>

Link to comment
Share on other sites

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.