maxxd Posted February 19, 2019 Share Posted February 19, 2019 (edited) 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. Edited February 19, 2019 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/308343-help-with-undefined-variable-error/page/2/#findComment-1564620 Share on other sites More sharing options...
Chrisj Posted February 19, 2019 Author Share Posted February 19, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/308343-help-with-undefined-variable-error/page/2/#findComment-1564625 Share on other sites More sharing options...
maxxd Posted February 20, 2019 Share Posted February 20, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/308343-help-with-undefined-variable-error/page/2/#findComment-1564633 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.