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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.