php require not functioning

Status
Not open for further replies.

massimo

New Member
Messages
42
Reaction score
0
Points
0
Hi all,

I'm using a php require to include another file which has worked fine, until I checked my site yesterday. Here's the code I've been using.

Code:
<?php require $_SERVER["DOCUMENT_ROOT"] . "/includes/top.php"; ?>
Standard stuff. What's weird is that I'm using the same code on all pages but only get the following warning on some pages and not others.

Code:
Warning:  require() [[URL="http://www.krazybov.com/advertise/function.require"]function.require[/URL]]:  open_basedir restriction in effect.  File(/usr/local/apache/htdocs/includes/top.php) is not within the  allowed path(s): (/home/:/tmp) in /home/massimo/public_html/krazybov.com/advertise/index.php  on line 1

Warning:  require(/usr/local/apache/htdocs/includes/top.php) [[URL="http://www.krazybov.com/advertise/function.require"]function.require[/URL]]:  failed to open stream: Operation not permitted in /home/massimo/public_html/krazybov.com/advertise/index.php  on line 1

Fatal error:  require() [[URL="http://www.krazybov.com/advertise/function.require"]function.require[/URL]]:  Failed opening required '/usr/local/apache/htdocs/includes/top.php'  (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/massimo/public_html/krazybov.com/advertise/index.php  on line 1
Warning appears on this page http://www.krazybov.com/001/

No warning on this page http://www.krazybov.com/contact/

A solution that doesn't involve me going into every page to change the php require would be much appreciated.

Got any bright ideas? I'm stumped!
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Unfortunately, $_SERVER["DOCUMENT_ROOT"] seems to be the culprit with the new server configuration.

Seems like you will have to go in and change it to "/home/yourcPanelUsername" in all your scripts.

Hmmmm. Not sure if there is a way to use .htaccess for this. I will try to Google up some things but no promises.

Edit/Add: if you have a huge amount of scripts with this problem, you might think about a script that will do the editing en masse.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Well, .htaccess is a no go. You can set environment variables there . You can unset DOCUMENT_ROOT . But it won't let you set DOCUMENT_ROOT. I tried.
Not sure if that is Apache or just x10's settings.
 

pierre39

New Member
Messages
38
Reaction score
0
Points
0
I got 500 error with requesting a Mysql function...

It seems there is a bug in the x10hosting or apache setting..??

Is it possible to get a solution ?? what to do ?

Thanks to all, technicians operating the x10 servers... Keep on but tell us the progress on this issue

Peter
 

massimo

New Member
Messages
42
Reaction score
0
Points
0
Thanks Descalzo, looks like I have a lot of cutting and pasting to do :(

What's really puzzling is why the same code works on some pages but not others. I don't mind fixing the problem (honestly) but sometimes I just like to know why / what's causing the problem.
 
Status
Not open for further replies.
Top