wmguk Posted December 8, 2010 Share Posted December 8, 2010 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 More sharing options...
PFMaBiSmAd Posted December 8, 2010 Share Posted December 8, 2010 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 More sharing options...
wmguk Posted December 8, 2010 Author Share Posted December 8, 2010 ah ha, != '' worked! Thank you Link to comment https://forums.phpfreaks.com/topic/221064-problem-with-isset/#findComment-1144642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.