Jump to content

isset still not working


Monkuar

Recommended Posts

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

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 = '';

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.