tags:

views:

75

answers:

3

How to get $schedule = true` and $schedule2 = true to work???

I know this is easy and I'm overlooking something simple!

Hi. Sorry for the obscure code, here is the full code :

I basically want schedule and schedule2 to work (it looks at php date and tells it when to expire on our news site!)

$where = array();
$where = run_filters('also-allow', $where);

if ($allow_full_story or $allow_add_comment){
    $post = 'full';

    if ($title){
        $where[] = "url = $title";
    } elseif ($time){
        $where[] = "date = $time";
    } elseif ($id){
        $where[] = "id = $id";
    }
} else {
    $post = 'short';

    if (!$is_logged_in or $is_logged_in and $member['level'] == 4){
        $where[] = 'hidden = 0';
        $where[] = 'and';
    }

    if ($user or $author){
        $where[] = 'author = '.($author ? $author : $user);
        $where[] = 'and';
    }

    if ($year and !$month){
        $where[] = 'date > '.@mktime(0, 0, 0, 1, 1, $year);
        $where[] = 'and';
        $where[] = 'date < '.@mktime(23, 59, 59, ($year == date("Y") ? date("n") : 12), ($year == date("Y") ? date("d") : 31), $year);
    } elseif ($year and $month and !$day){
        $where[] = 'date > '.@mktime(0, 0, 0, $month, 1, $year);
        $where[] = 'and';
        $where[] = 'date < '.@mktime(23, 59, 59, $month, (($year == date("Y") and $month >= date("n")) ? date("d") : 31), $year);
    } elseif ($year and $month and $day){
        if($year == date("Y") and $month >= date("n") and $day >= date("d")){
            $where[] = 'hidden = 2';
        }
        else{
            $where[] = 'date > '.@mktime(0, 0, 0, $month, $day, $year);
            $where[] = 'and';
            $where[] = 'date < '.@mktime(23, 59, 59, $month, $day, $year);
        }
    } 
    else {
    if ($schedule) {
        $where[] = 'date > '.(time() + $config_date_adjust * 60 - 432000);
    }
    else {
        $where[] = 'date < '.(time() + $config_date_adjust * 60);
    }

    $schedule = false;
}
else {
    if ($schedule2) {
        $where[] = 'date > '.(time() + $config_date_adjust * 60 - 86400);
    }
    else {
        $where[] = 'date < '.(time() + $config_date_adjust * 60);
    }

    $schedule2 = false;
}
+6  A: 

you can't have 2 else in a row
may be elseif but noone know your logic

Col. Shrapnel
He only has 1 `else` for each `if`. If you look closely, you will see. (Granted, the code formatting is atrocious)
webdestroya
Nah, it has else else in it: `else {... $schedule = false;} else{ if(...` I checked it in Netbeans.
SeanJA
A: 

you use to many else, try to simplify your code, use CASE

cosy