08-14-2009, 01:23 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
$_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)?
__________________
|
|
|
|