Jump to content

[SOLVED] ENUM and IF's


anser316

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.