...

View Full Version : If the page doesn't exist I get an error



nikos101
12-12-2008, 09:47 PM
Hi coders, long time no see!

Ok heres my problem:

I use this to pull in content

if( isset($_GET['page'])){
include('pages/'.$_GET['page'].'.php') ;

}

However if the page doesn't exist I get an error. What is the best way to check for this?

CFMaBiSmAd
12-12-2008, 09:55 PM
http://us2.php.net/file_exists

oesxyl
12-12-2008, 09:57 PM
Hi coders, long time no see!

Ok heres my problem:

I use this to pull in content

if( isset($_GET['page'])){
include('pages/'.$_GET['page'].'.php') ;

}

However if the page doesn't exist I get an error. What is the best way to check for this?

use file_exists to check if a file with this name exists.

http://www.php.net/manual/en/function.file-exists.php

also read the note about symlinks.

best regards

nikos101
12-12-2008, 10:51 PM
thanks coders that worked a treat



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum