shage Posted July 2, 2007 Share Posted July 2, 2007 $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 Quote Link to comment Share on other sites More sharing options...
corillo181 Posted July 2, 2007 Share Posted July 2, 2007 is mailist a define code? Quote Link to comment Share on other sites More sharing options...
shage Posted July 2, 2007 Author Share Posted July 2, 2007 $insert_query = "INSERT INTO ".MYSQL_TBL_MAILLIST_BLACKLIST." VALUES ('$_POST[rule]')"; it was that code bust instead of the user posting what to blacklist the script does it after the user unsubs Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 2, 2007 Share Posted July 2, 2007 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 } ?> Quote Link to comment 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.