Kryllster Posted August 28, 2008 Share Posted August 28, 2008 I have been looking since I lost all my stuff from hard drive crash I dont understand why this code isnt working any more <?php // Show Header View include('page/header_view.php'); // navigation // Show Header View include('page/navigation_view.php'); //Setup the url var we are looking for to control page display $show = $_GET['show']; switch($show){ case 'johnpeggy': include('page/johnpeggy_view.php'); break; case 'contact': include('page/contact_view.php'); break; case 'downloads': include('page/downloads_view.php'); break; case 'news': include('news/news_view.php'); break; case 'chat': include('page/chat_view.php'); break; case 'main': default: include('page/main_view.php'); break; } include('page/footer_view.php'); ?> I get this error :Notice: Undefined index: show in C:\Apache2\htdocs\index.php on line 10 I just don't understand, today has not been my day!! Thanks Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/ Share on other sites More sharing options...
JasonLewis Posted August 28, 2008 Share Posted August 28, 2008 Instead of just declaring it, you should do it like this: if(!isset($_GET['show'])){ //There is no ?show= in the url, set it as a default $show = "johnpeggy"; }else{ //?show= is present $show = $_GET['show']; } Or you can show all errors except NOTICE's: error_reporting(E_ALL ^ E_NOTICE); Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/#findComment-627717 Share on other sites More sharing options...
MasterACE14 Posted August 28, 2008 Share Posted August 28, 2008 but your better off doing the first one Project Fear mentioned Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/#findComment-627720 Share on other sites More sharing options...
JasonLewis Posted August 28, 2008 Share Posted August 28, 2008 Of course. Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/#findComment-627722 Share on other sites More sharing options...
Kryllster Posted August 28, 2008 Author Share Posted August 28, 2008 I have never had to do this before what has changed I don't understand. I tried another version of the isset but it didn't work but this worked. Thanks for the replies! Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/#findComment-627727 Share on other sites More sharing options...
JasonLewis Posted August 28, 2008 Share Posted August 28, 2008 Maybe before your php.ini settings were different. Error reporting may have been set to not have notices shown. But it's best to show errors when developing scripts. Link to comment https://forums.phpfreaks.com/topic/121685-solved-a-really-bad-hair-day/#findComment-627729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.