Jump to content

Recommended Posts

Posted

Hi,

 

I have created my website around php and it all works/worked fine, untill i decided it was a good idea to move my file containing my databse password and connections settings to

 

****

instead of it residing in ****/html_public

 

Naturally i changed all my other files that refereced this file.

 

eg files that reside in html_public had

 

include 'myconnections.php'; became include '../myconnections.php'

 

and for the most part it works fine, but i have really big issue with a file that references it in

 

html_public/exampledir/ with include '../../myconnections.php'

 

it just does like it , i dont get the usual, cant find it error, i get

 

Warning: main(): open_basedir restriction in effect. File(../../../myconnections.php) is not within the allowed path(s): (/home/MYUSERNAME:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/ypgympj/public_html/exampledir/checks.php on line 4

 

ive been told its something todo with the configuration, but this is were i need your help. What do i do from here

Thoughts much appreciated.

 

Take Care

G_N

Posted

You can use

 

include $_SERVER['DOCUMENT_ROOT']."/myconnections.php'";

 

or if in a folder inside public_html

 

include $_SERVER['DOCUMENT_ROOT']."/folder/myconnections.php'";

Posted

i can still use that if myconnections reside in the the folder above public_html ???

 

the folder that lists:

etc

mail

public_html

public_ftp

tmp

myconnections.php

 

this is were i am trying to put my connections file as i thought it would be the safest

thanks

 

G_N

Posted

Your example is basically a script located here:

/home/cpanelName/public_html/exampledir/myscript.php

...with include '../../myconnections.php'

 

The error message is indicating that your script is looking for myconnections three directories above your script, not two:

Warning: main(): open_basedir restriction in effect. File(../../../myconnections.php) is not within the allowed path(s):

Three directories above /home/cpanelName/public_html/exampledir is the /home directory, which outside of PHP's open_basedir() restrictions, not to mention that /home is a directory that you don't have permission to access nor should be trying to access.

 

You need to locate the line in your script that is trying to include the myconnections.php file by going up 3 directories and change it so that it is only going up 2 directories, like what you posted in your "example".

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...