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 Quote Link to comment 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); Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 28, 2008 Share Posted August 28, 2008 Of course. Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment 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.