Jump to content

[SOLVED] A really bad hair day


Kryllster

Recommended Posts

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

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);

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.