Page 1 of 1
Need some help here
Posted: Wed Jun 19, 2002 2:59 pm
by ibelimb
ok i have this code:
Code: Select all
<?
if ($page == "") then {
include "news.php"
} else {
include $page
}
?>
and i get a parse error, how do i fix this, im calling the page like this: index.php?page=test.php
and i get the parse error, i also need some help fixing it up so that if the user calls a bad page, it displays a error (includes a file like error.php) and if no ?Page= was called it goes to news.php
Any help would be appreciated!
thanks,
Limb
Posted: Wed Jun 19, 2002 3:19 pm
by twigletmac
You forgot the semi-colons (;) at the end of the lines, try:
Code: Select all
<?
if ($_GETї'page'] == '') then {
include 'news.php';
} else {
include $_GETї'page'];
}
?>
Mac
Posted: Wed Jun 19, 2002 3:19 pm
by kaizix
Code: Select all
<?
if ($page == "")
{
include ("news.php");
}
else
{
include ("$page");
}
?>
original code was missing ; and there's no then code is fixed above...also, if you're just starting to code...i would suggest getting into the habit of making the code more understandable when going through it...(as above)
also, to fix if a user has a bad page, you could put all the pages that someone would include into an array and see if it's in there...if not, go to error page. another way to do it if they have nothing is isset
Code: Select all
if(!isset($page))
{
include("news.php");
}
Posted: Wed Jun 19, 2002 3:29 pm
by Eugene
try something like this:
Code: Select all
if ($_GETї'page'] == NULL)
{
include "news.php";
}
else
{
if (!(include $_GETї'page'])) {include "error.php";}
}
I think it could work, eventhough I am not sure about second if statement
Eug
Posted: Wed Jun 19, 2002 3:40 pm
by ibelimb
thnaks, im nto really new i was leanrign c++ so i was getting mixed with the two languages.