PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
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
<?
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