Hello,

It seems my IF ($email_settings == "0") isnt working properly.

I am trying to get it so that IF a setting in a table field is set to 0 then it continues and executes the info between the {} which is to send an email. However, if the IF is set to 1 then it wont send the email.

Im not sure if its the IF I have wrong or the $email_settings that I have set wrong.

Ive tried a couple things such as having

if ($email_settings == "0")
if ($email_settings == 0)
if ($email_settings == '0')


but none of these seem to work!

If I use the IF ($email_settings == "0") then it doesnt send an email regardless of the setting.

However, if I use the IF ($email_settings == 0) then it sends it regardless of the setting.


Please help .... here is the segment of code

$emailsubject = "$send_to, you have a message at CyberPetWorld.com !!!.";


$members = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");

$members_profiles = fetch("SELECT * FROM members_profiles2 WHERE username = '$send_to' AND game = '$game'");

$getEmail = $members_profiles[email];

$emailaddress ="mail@cyberpetworld.com";

$email_settings = fetch("SELECT mail FROM mail_settings WHERE user_id = '$send_to' AND game = '$game'");
	



if ($email_settings == "0")
{
	
	 mail($getEmail,$emailsubject,$emailmessage,"From: $emailaddress \nContent-Type: text/html; charset=iso-8859-1\r\nMime-Version: 1.0\nContent-Transfer-Encoding: 7bit");
	
}

Can I ask how do I check on fetch?

The table is named mail_Settings and the mail field is either 0 or 1. :>/

thanks

Can I ask how do I check on fetch?

The table is named mail_Settings and the mail field is either 0 or 1. :>/

thanks

What does "fetch" do? It is not a php function as far as I can tell. Try echoing all your variables on a page and see what they return.

What does "fetch" do? It is not a php function as far as I can tell. Try echoing all your variables on a page and see what they return.

Sorry, found out that Fetch is part of the PDO abstraction layer. I think that fetch() is returning a row of data even if only one column of data. Try $email_Settings[0] or $email_Settings and see if that doesn't return the value.

However, if I use the IF ($email_settings == 0) then it sends it regardless of the setting.

$email_settings == 0 will always work if $email_settings is false as well as 0. Try using $email_settings === 0 and that will check to make sure that $email_settings is an integer as well as equal to 0(not false)

Hi davedpss,

Thanks for your reply.

I have tried the $email_settings === 0 and that didnt seem to work. It just seemed to stop it altogether from working! :>/

Im reallt stumped on what it could be!

Hello ! I just read all reply and why don't you try $email_settings === 0 ?

$email_settings is the result of a query so to access to his value, the syntax must be $email_settings, no ?

This article has been dead for over six months. Start a new discussion instead.