I have to include a file stored in a database and retrieved as a variable. how can I do it? I have tried this line but it doesn't work include_once("News/$post->newspage"); the fild newspage contains the names of the files stored in News folder. for example his line works. include_once("News/labourday2014.php");
4 Answers
Verify if the file exist then include it
if(is_file("News/".$post->newspage)) {
include_once("News/".$post->newspage);
} else {
// File dosent't exist
echo "File dosent't exist";
}
1 Comment
Principe Camake
I have checked the existance of the file but I still get the same error.Warning: include_once(/home2/umutarap/public_html/nyagatareweb_dev/News) [function.include-once]: failed to open stream: Success in /home2/umutarap/public_html/nyagatareweb_dev/index.php on line 141 Warning: include_once() [function.include]: Failed opening 'News/' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home2/umutarap/public_html/nyagatareweb_dev/index.php on line 141