Monkuar Posted February 7, 2012 Share Posted February 7, 2012 if (isset($_COOKIE['hide_div']['0']) && isset($_COOKIE['hide_div']['2'])){ $cookie1 = $_COOKIE['hide_div']['0']; $cookie2 = $_COOKIE['hide_div']['2']; } if ($cookie1 == $cat_id OR $cookie2 == $cat_id) { foreach ($this->forums as $forum_id => $forum_data) { if ($forum_data['category'] == $cat_id) { //----------------------------------- // We store the HTML in a temp var so // we can make sure we have cats for // this forum, or hidden forums with a // cat will show the cat strip - we don't // want that, no - we don't. //----------------------------------- $temp_html .= $this->process_forum($forum_id, $forum_data); } } if ($temp_html != "") { $this->output .= $this->html->CatHeader_Expandedhidden($cat_data); $this->output .= $this->html->end_this_cat(); } unset($temp_html); }else{ $cookie1 = ''; $cookie2 = ''; why in the world is it displaying Undefined variable: cookie1 and cookie2 as errors? When I declared both of them even AFTER my if statement, this is bogus dude, lol this isset stuff is really confusing or am i just not doing it right? Link to comment https://forums.phpfreaks.com/topic/256581-isset-still-not-working/ Share on other sites More sharing options...
Stooney Posted February 7, 2012 Share Posted February 7, 2012 If the cookies aren't set in the first place, $cookie1 and $cookie2 don't get declared at all. <?php //declare the vars $cookie1=0; $cookie2=0; if (isset($_COOKIE['hide_div']['0']) && isset($_COOKIE['hide_div']['2'])){ $cookie1 = $_COOKIE['hide_div']['0']; $cookie2 = $_COOKIE['hide_div']['2']; } if ($cookie1 == $cat_id OR $cookie2 == $cat_id) { foreach ($this->forums as $forum_id => $forum_data) { if ($forum_data['category'] == $cat_id) { //----------------------------------- // We store the HTML in a temp var so // we can make sure we have cats for // this forum, or hidden forums with a // cat will show the cat strip - we don't // want that, no - we don't. //----------------------------------- $temp_html .= $this->process_forum($forum_id, $forum_data); } } if ($temp_html != "") { $this->output .= $this->html->CatHeader_Expandedhidden($cat_data); $this->output .= $this->html->end_this_cat(); } unset($temp_html); }else{ $cookie1 = ''; $cookie2 = ''; Link to comment https://forums.phpfreaks.com/topic/256581-isset-still-not-working/#findComment-1315349 Share on other sites More sharing options...
Monkuar Posted February 7, 2012 Author Share Posted February 7, 2012 fixed this by simpling adding this: if (!isset($_COOKIE['hide_div']['0'])){ $_COOKIE['hide_div']['0'] = 0; } if (!isset($_COOKIE['hide_div']['2'])){ $_COOKIE['hide_div']['2'] = 0; } rofl i think I am thinking to hard? Link to comment https://forums.phpfreaks.com/topic/256581-isset-still-not-working/#findComment-1315351 Share on other sites More sharing options...
Deoctor Posted February 7, 2012 Share Posted February 7, 2012 Try this if (!isset($_COOKIE['hide_div']['0']) || !isset($_COOKIE['hide_div']['2'])){ $cookie1 = $_COOKIE['hide_div']['0']; $cookie2 = $_COOKIE['hide_div']['2']; } Link to comment https://forums.phpfreaks.com/topic/256581-isset-still-not-working/#findComment-1315360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.