u can use any folder inside public_html or there itself
U can use include function in any php file to link it
For eg
<?php
include("includes/connection.php") // includes is the folder where connection.php is located
?>
if i want to include a sensitive file like a database login, where should i place the file when i upload to x10hosting server? if my root directory is public_html/www.mywebsite.com do i place it at public_html/databaselogin folder? and how do i link to that file using php include?
thank you very much.
u can use any folder inside public_html or there itself
U can use include function in any php file to link it
For eg
<?php
include("includes/connection.php") // includes is the folder where connection.php is located
?>
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
but the php include function only allows me to include files that are in my root folder which in this case is public_html/www.mysite.com. i want to store my database login above the root folderlike public_html/databaselogin for security purposes.
U mean outside the root folder i e.(www.mysite.com -root) and u wanna place databaselogin in public_htnl or wht
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
yes i would like to place the file outside the root folder. and use php include to put it on my site.
Since the database login is in the root folder u should use
<?php
include("databaselogin.php") // since in root folder no path is req
?>
try this this must solve ur problem
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
my root folder is public_html/mysite.com. the database login file is in public_html/databaselogin folder which is outside the root folder. so the php include you wrote wont work.
Try referring absolute path....
Is this a addon domain.
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
ok i figured it out myself already. thanks anyway ;).
I lol'd :p
If you want to "secure" a script, don't put it in public_html at all, you can put it even higher than that. (eg. make a directory nonpublic_html)
As vishal2 (finally) noticed in the end, you can use absolute paths ("/home/username/public_html/script.php" for example), or perhaps easier: relative paths can do this too.
To refer to the directory above the one you're currently in, use "..".
So, if you have a script in public_html/site.com and want to refer from there to a script public_html/nonpublic/script.php, you can use
Edit: sorry, too latePHP Code:include "../nonpublic/script.php";
![]()
Last edited by marshian; 01-10-2010 at 06:18 AM.
Real programmers don't document their code - if it was hard to write, it should be hard to understand.