Jump to content

Recommended Posts

Hi. This is a column and its constraints which i have added in a table on mysql

 

exemption_type	ENUM('NO','YES') NOT NULL,

 

The default value is 'NO' which i intend it to be.

I insert the exemption_type on a php form, and it shows that it is inserted. On a linked php form i have:

if ($row[exemption_type]=Yes){
some code
}
else if($row[exemption_type]=No){
some code
}
else
echo "Error";

 

For some reason it always executes the first if statement, whether its Yes or No. I would appreciate some help, thanks.

Link to comment
https://forums.phpfreaks.com/topic/100491-solved-enum-and-ifs/
Share on other sites

that's because you're using the assignment operator, you should use "==" without the quotes, you should also add quotes to Yes and No

 

so your code should look like this

 

if ($row[exemption_type]=='Yes'){
some code
}
else if($row[exemption_type]=='No'){
some code
}
else
echo "Error";

 

Link to comment
https://forums.phpfreaks.com/topic/100491-solved-enum-and-ifs/#findComment-513915
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.