Jump to content

Simple IF statement not working


figuringout

Recommended Posts

I'm struggling to understand why this doesnt work. I have an array which I breakdown annd assign the various parts off to variables, then want to test if one is NULL if it is ignore it.

 

$supplierEmail = $supplierarray[0];
$supplierId = $supplierarray[1];
$supplierEmail2 = $supplierarray[2];

 

in some cases $supplierEmail2 is null so I want to ignore it, so I thought I could do this.

 

if ($supplierEmail2 == "NULL")
echo "No email";
else
echo $supplierEmail2 . "<br />";

 

this doesnt work and I cant figure out why. I even set the field to be something other than null and test it but still I dont get the results I thought I would get.

Link to comment
Share on other sites

I've tried everything you all suggested but still it does not work. What else could it be?

 

The data is coming from a form.

$supplier = $_POST[suppliers_info];
$supplierarray = explode(",",$supplier);
$supplierEmail = $supplierarray[0];
$supplierId = $supplierarray[1];
$supplierEmail2 = $supplierarray[2];

 

then I test the variable $supplierEmail2 to see if is empty but it always returns true. I've even set the field in the database to be 'none' and tried to test for this, but still it doesnt work.

Is it something to do with the variable coming from an array?

 

 

 

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.