Jump to content

problem with isset


wmguk

Recommended Posts

Hey,

 

I've got a site and I need to query a database to check if there is a result. If there isnt then I need a default result...

 

//Check the database and get a result
$skinName = strtolower(get_post_meta($post_id, $key, $single));


if (isset($skinName)) 
{ 
//If there is a result, then use it
$skinName = strtolower(get_post_meta($post_id, $key, $single));
} else {
//If NO result then use RED
$skinName = 'red';
}

//Build up the var to show REDsite
$skinName = $skinName . 'site';

 

For some reason the above doesnt work.

If there is a result then it uses it, however if there is no result then it simply shows "site" - not "redsite" like it should do.

 

Any ideas what I missed?

Link to comment
https://forums.phpfreaks.com/topic/221064-problem-with-isset/
Share on other sites

Most form fields will be set, even if they are empty. You should probably be using empty or != '' (not equal to an empty string), depending in what sort of values you are expecting (a zero is considered to be an empty value by the empty() function.)

Link to comment
https://forums.phpfreaks.com/topic/221064-problem-with-isset/#findComment-1144634
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.