Reply
CMS - content script help
Old 01-14-2009, 07:30 PM CMS - content script help
Junior Talker

Posts: 1
Trades: 0
hello i need help.

im using this script
PHP Code:
<?PHP
/*include("classic/".$id .".php");*/
if(!isset($_GET['id'])){
    
$page "main";
    }
    
else {
    
$id $_GET['id'];
    }
  
if(
file_exists("classic/".$id .".php")){
    include(
"classic/".$id .".php");
    }
else {

/* Put your own error message or some other content.  
    Even a redirect to the main page would work           */                                            
include("classic/main.php");
}
?>
the linking works fine. but when the home page. it shows
Notice: Undefined variable: id in classic.php on line 135

and line 135 is
PHP Code:
if(file_exists("classic/".$id .".php")){ 

is there something i missed? is there a better way to do this?
the server im using is a windows server but using php5.

please help me

thanks
iregistered is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 01-14-2009, 08:10 PM Re: CMS - content script help
NullPointer's Avatar
Will Code for Food

Latest Blog Post:
Easy PHP Search with Opera
Posts: 1,070
Name: Matt
Location: Irvine, CA
Trades: 0
In the case that $_GET['id'] is not set you still execute the line that you get the error on. So you need to either set id to something in your if statement, or you need to put your second if/else within your first else statement. So either:
PHP Code:
<?PHP
/*include("classic/".$id .".php");*/
if(!isset($_GET['id'])){
    
$page "main";
    
$id 'something';
    }
    
else {
    
$id $_GET['id'];
    }
  
if(
file_exists("classic/".$id .".php")){
    include(
"classic/".$id .".php");
    }
else {

/* Put your own error message or some other content.  
    Even a redirect to the main page would work           */                                            
include("classic/main.php");
}
?>
OR

PHP Code:
<?php
/*include("classic/".$id .".php");*/
if(!isset($_GET['id'])){
    
$page "main";
    }
    
else {
       
$id $_GET['id'];
       if(
file_exists("classic/".$id .".php"))
       {
           include(
"classic/".$id .".php");
      }
      else 
     {

          
/* Put your own error message or some other content.  
              Even a redirect to the main page would work           */                                            
          
include("classic/main.php");
    }
}
  
?>
__________________
Tinsology | How to Post Code | EverythingDev

Last edited by NullPointer; 01-14-2009 at 08:11 PM..
NullPointer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to CMS - content script help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11435 seconds with 13 queries