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? Quote 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.) Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/221064-problem-with-isset/#findComment-1144642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.