I have three errors: Code: Warning: include() [[URL="http://midaevon.pcriot.com/function.include"]function.include[/URL]]: URL file-access is disabled in the server configuration in /home/emiiya/public_html/index.php on line 3 Warning: include([URL]http://midaevon.pcriot.com/mainlayout.php[/URL]) [[URL="http://midaevon.pcriot.com/function.include"]function.include[/URL]]: failed to open stream: no suitable wrapper could be found in /home/emiiya/public_html/index.php on line 3 Warning: include() [[URL="http://midaevon.pcriot.com/function.include"]function.include[/URL]]: Failed opening 'http://midaevon.pcriot.com/mainlayout.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/emiiya/public_html/index.php on line 3 On line 3 of index.php, I include a file called mainlayout.php, which is basically where the header and layout of the site are coded, all neatly in one file for easy access and changes. I originally had a bookmarking system where it would fetch the URL, but after first googling this problem, I figured out that this wasn't allowed so I removed that chunk of code and just put $url="doesnt work yet" for the time being until I figure out another way to do this. However, the problem still persists, and I'm stumped. The scripts worked on another host, but here they don't seem to. I can provide code if necessary, but first, any suggestions?
Make the header into a function, then make a template and were the header is, call your header function.
First few lines of index: PHP: <? $title="Midaevon || Home"; include("http://midaevon.pcriot.com/mainlayout.php"); ?> (the title is for something else later in the code, it has nothing to do with the include) I tried /mainlayout.php, and the first error went away, however the second two remained. Warning: include(/mainlayout.php) [function.include]: failed to open stream: No such file or directory in /home/emiiya/public_html/index.php on line 3 Warning: include() [function.include]: Failed opening '/mainlayout.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/emiiya/public_html/index.php on line 3
the server is linux. So check the filename . It is case sensitive. mainlayout.php is different to MainLayout.php Check the file mainlayout.php is in public_html
Everything's where it should be, and spelling is correct. I tried include("mainlayout.php"); without the slash, and it worked for the most part (bringing up a bunch of new errors now but I'm pretty sure I can fix those now). What should I do if I have other files in folders? Will include("../mainlayout.php"); work when I try to include it in folders or is there another method I should be using?
Try this: PHP: include("$_SERVER['DOCUMENT_ROOT']/mainlayout.php"); The file mainlayout.php should be in public_html folder to work this also make sure the permission of file is set to 644
To make include-ing from arbitrary directories easier, use set_include_path. Read "RE: php include - above root directory" for details.