Hello,
I have a table which is currently emply named client_options.
When the e-mail address is not found I want to insert a record into the table. If the e-mail is found in the table, I want to update the field.
Currently, as you can see from my output this is not happening. I thought the !$result condition would be true when the table cann;t find the record and insert the record. It is instead performing the update.
Why is this happening?? Is their a better way to perform this check? Any help would be appreciated.
Gary
test001 Resource id #3 test003 test004
$query = "SELECT * FROM client_options WHERE client_email_address = '$email_address_1'";
$result = mysql_query($query) or die ("Can't connect [ 001 ] because ".mysql_error());
echo "test001";
echo "$result";
if (!$result) {
die('Invalid query: ' . mysql_error());
}
if (!$result) {
/ --------------------- Insert Information | [ CLIENT_OPTIONS ] Table ------------------- /
echo "test002";
$query = "INSERT INTO client_options VALUES ('', '$email_address_1', '$status', '', '', '', '', '', '', '', '', '', '', '')";
mysql_query($query) or die ("Can't connect because [ 002 ]".mysql_error()); }
else {
/ ------------------ Update Information | [ CLIENT_OPTIONS ] Data Base ------------------ /
echo "test003";
$query="UPDATE client_options SET unsubscribe_email_messages='$status' WHERE client_email_address = '$email_address_1'";
mysql_query($query) or die ("Can't connect because [ 003 ]".mysql_error()); }
echo "test004";
?>