php include - above root directory

vishal

-::-X10 Guru-::-
Community Support
Messages
5,255
Reaction score
192
Points
63
i created a folder home/user/Database and i put the database login file in that folder using php include.

include_once '/home/user/Database/db_connect.php';

and it gave this error.

include_once(/home/user/Database/db_connect.php) [function.include-once]: failed to open stream: No such file or directory
Its because the path o the folders are set with user permissions for eg RWX.?In order to access u must have to enable this to RWX or atlest RX..
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
i created a folder home/user/Database and i put the database login file in that folder using php include.

include_once '/home/user/Database/db_connect.php';

and it gave this error.

include_once(/home/user/Database/db_connect.php) [function.include-once]: failed to open stream: No such file or directory

Make sure that 'user' is your cPanel username
Make sure that the directory Database (not database ... capitalization matters) has permissions 755
Make sure db_connect.php is the correct spelling/capitalization.

EDIT/ADD

The error I see now on your site is:

Warning: include_once(db_connect.php) [function.include-once]: failed to open stream: No such file or directory in /home/XXXXX/public_html/index.php on line

that does not look like the path you described.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
if my root folder is /home/user/public_html/mysite.com and i put my database log in file above my root site but still under public_html folder. why wont it be safe? cause my root directory is still /home/user/public_html/mysite.com and people cant access files above my root directory if they access my website right?

~/public_html/mysite.com would be the doc root for an addon domain. ~/public_html is the doc root for your primary domain. Anything under ~/public_html is accessible through the primary domain, unless you take steps to secure it.
 

vishal

-::-X10 Guru-::-
Community Support
Messages
5,255
Reaction score
192
Points
63
tillabong u first try it in your local pc.Then upload it in ur server and chek. Double sure u had all ur parameters is correct.As far as i am conserned it was possible to refer relative path.It must be some permisson issue or some parameters
 

tillabong

New Member
Messages
60
Reaction score
0
Points
0
im sure i got the path correct the capitalization and user and stuff. how do i change the permission thingy?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
how do i change the permission thingy?
You can use cPanel file manager. Many FTP clients also support changing permissions. All directories in the path to the script need, at minimum, read & execute permissions for the user (mode 0500); the most permissive mode you should use is 0755. Scripts need at least read permisson (mode 0400); their most permissive mode should be 0644.
 
Top