Fitzlegend Posted April 24, 2008 Share Posted April 24, 2008 Hi i am converting a script from localhost to my web server, im getting an error with a file http://nci.890m.com/Nciworkplacement/ include($_SERVER['DOCUMENT_ROOT'].'/'.'Nciworkplacement/views/layouts/'.$controller.'.php'); It worked this way on localhost the errors i now get are Warning: include() [function.include]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/Nciworkplacement/views/layouts/jobs.php) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a3013388/public_html/Nciworkplacement/index.php on line 52 Warning: include(/usr/local/apache/htdocs/Nciworkplacement/views/layouts/jobs.php) [function.include]: failed to open stream: Operation not permitted in /home/a3013388/public_html/Nciworkplacement/index.php on line 52 Warning: include() [function.include]: Failed opening '/usr/local/apache/htdocs/Nciworkplacement/views/layouts/jobs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3013388/public_html/Nciworkplacement/index.php on line 52 On wamp i had it in my www folder on my web server i also have it in my www folder. Can anyone solve the error? Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Confirm the absolute path is correct, or don't user absolute paths, try relative instead. Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 can i use a different method than ($_SERVER['DOCUMENT_ROOT']. Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 I'd create a BASE_URL define and then just refer to that instead. Quote Link to comment Share on other sites More sharing options...
haku Posted April 24, 2008 Share Posted April 24, 2008 You should always use relative URLs anyways. Why you may ask? Because it prevents this exact problem when you put your script on a different server. Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 I definitely agree, any particular reason you're not using them? Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 No it was a script that i followed, im very new to php. So if i use a relative url it should fix the error? Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 It should Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 Ok great, do i still need to use the include part? include($_SERVER['DOCUMENT_ROOT'].'/'.'Nciworkplacement/views/layouts/'.$controller.'.php');?> what way would i write it? Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 No write it like this: include('../views/layouts/'.$controller.'.php');?> // assuming Nciworkplacement is the main folder for this project. Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 down to 2 now Warning: include(../views/layouts/jobs.php) [function.include]: failed to open stream: No such file or directory in /home/a3013388/public_html/Nciworkplacement/index.php on line 57 Warning: include() [function.include]: Failed opening '../views/layouts/jobs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3013388/public_html/Nciworkplacement/index.php on line 57 they are both the only files using the server document root, i have put them in the public_html folder... does this error mean they are not? Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 The error means the relative path is incorrect. Give us the folder the current file is in, and the name of the folder the other files are in. Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 ... Quote Link to comment Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 The two of them are located below. /www/Nciworkplacement/index.php /www/Nciworkplacement/views/layouts/jobs.php Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 include ('./views/layouts/jobs.php'); Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Or include ('views/layouts/jobs.php'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.