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? Link to comment https://forums.phpfreaks.com/topic/102731-error/ 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. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526111 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']. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526119 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. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526124 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. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526130 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? Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526133 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? Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526143 Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 It should Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526147 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? Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526157 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. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526161 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? Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526166 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. Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526174 Share on other sites More sharing options...
Fitzlegend Posted April 24, 2008 Author Share Posted April 24, 2008 ... Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526187 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 Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526190 Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 include ('./views/layouts/jobs.php'); Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526195 Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Or include ('views/layouts/jobs.php'); Link to comment https://forums.phpfreaks.com/topic/102731-error/#findComment-526198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.