Thread: $_GET error
View Single Post
Old 08-14-2009, 12:23 PM   #1 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default $_GET error

Hi, I have a really weird error...

phpfile.php
PHP Code:

$year 
$_GET['year'];
        
        if(
is_numeric($year) || $year == 'current')
        {
        
            
$file 'subs/economy/' $year;
            
            if(
file_exists($temp->getFile($file))) 
            {
            
                
$temp->view($file);
                
            }
            
            else
            {
            
                
$data['msg'] = 'Sidan finns ej';
                
$temp->view('error'$data);
            
            }
            
        }
        
        elseif(!isset(
$year))
        {
        
            
$year 'current';
            
$temp->view('subs/economy/' $year);
        
        }
        
        else
        {
        
            
$data['msg'] = 'Sidan finns ej';
            
$temp->view('error'$data);
        
        } 
Viewing phpfile.php?year=2009 brings up the template subs/economy/2009.php. Viewing 2008.. well you get the point.

Problem is though, that if I'm just viewing phpfile.php it should set $year = 'current', but it gives me an undefined index error. Any ideas how I can set so if they give no parameter in the url, it should set the parameter to 'current'(it doesn't have to DISPLAY that in the url though)?
__________________
Tanax is offline  
Reply With Quote