Jump to content

Help with Undefined variable Error


Chrisj

Recommended Posts

If you're visiting the 'trending', 'latest', and 'top' pages and seeing 'HELLOcategory text here' on all three (or any of the three, actually), then something is wrong with either PT_Secure() or your use of it because the value of $page is never not 'category'.

Change

die("<pre>".var_export($page, true)."</pre>");

to

print("<pre>".var_export($page, true)."</pre>");

then visit the 'trending', 'latest', and 'top' pages and compare the output.

Link to comment
Share on other sites

Thanks for your reply.

After adding your suggestion and visiting each page, I see 'category' in the top right corner of a blank white page quickly (see attached) and then the page with this HELLOcategory text here

 

print("<pre>".var_export($page, true)."</pre>");

$text = 'default';
$cateogry_id = '';
$videos = array();
if ($page == 'trending') {
    $title  = $lang->trending;
    $db->where('privacy', 0);
    $videos = $db->where('time', time() - 172800, '>')->orderBy('views', 'DESC')->get(T_VIDEOS, $limit);
    $text = 'trending text here';
}

else if ($page == 'latest') {
    $title  = $lang->latest_videos;
    $db->where('privacy', 0);
    $videos = $db->orderBy('id', 'DESC')->get(T_VIDEOS, $limit);
    $text = 'latest text here';
}

else if ($page == 'top') {
    $title  = $lang->top_videos;
    $db->where('privacy', 0);
    $videos = $db->orderBy('views', 'DESC')->get(T_VIDEOS, $limit);
    $text = 'top text here';
}

else if ($page == 'category') {
    if (!empty($_GET['id'])) {
        if (in_array($_GET['id'], array_keys($categories))) {
            $pt->page_url_ = $pt->config->site_url.'/videos/'.$page.'/'.$_GET['id'];
            $category = PT_Secure($_GET['id']);
            $title    = $categories[$category];
            $category_id = "data-category='$category'";

            if (!empty($_GET['sub_id'])) {
                 $is_found = $db->where('type',PT_Secure($_GET['id']))->where('lang_key',PT_Secure($_GET['sub_id']))->getValue(T_LANGS,'COUNT(*)');
                if ($is_found > 0) {
                    $pt->page_url_ = $pt->config->site_url.'/videos/'.$page.'/'.$_GET['id'].'/'.$_GET['sub_id'];
                    $db->where('sub_category', PT_Secure($_GET['sub_id']));
                }
            }
            $db->where('privacy', 0);
            $category_old = str_replace('category__', '', $category);
            $videos   = $db->where('category_id = "' . $category . '" OR category_id = "' . $category_old . '"')->orderBy('id', 'DESC')->get(T_VIDEOS, $limit);
			$text = 'category text here';

        } else {
            header("Location: " . PT_Link('404'));
            exit();
        }
    }
}

Any additional help is appreciated.

 

 

cat.png

Link to comment
Share on other sites

8 hours ago, Chrisj said:

After adding your suggestion and visiting each page, I see 'category' in the top right corner

This means that the return value of PT_Secure($_GET['page']) is always 'category'. The problem is with PT_Secure() - check the documentation to make sure it's being used correctly.

Link to comment
Share on other sites

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.