marshian u made an important point...... good i support u
marshian u made an important point...... good i support u
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
If you want to make things really simple, put an init.php in ~/public_html and include it with a include_once($_SERVER['DOCUMENT_ROOT'] . '/init.php'). Within init.php, add top-level include paths:
If you want to get fancy, define a function to append to the include path:PHP Code:// add ~/include/php and doc root to include path
set_include_path(get_include_path()
. PATH_SEPARATOR . dirname($_SERVER['DOCUMENT_ROOT']) . '/include/php'
. PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT']);
If you're on paid hosting, you can set auto_prepend_file (with php_value in .htaccess) to make this even easier, including init.php implicitly. At that point you can set include_path directly, but doing it in init.php means it's auto-configuring; you don't need to have a different configuration for your development and live servers.PHP Code:function addToIncludePath($path) {
$currIncPath = get_include_path();
if (!preg_match('#(^|' . PATH_SEPARATOR . ')'.preg_quote($path, '#').'(' . PATH_SEPARATOR . '|$)#', $currIncPath)) {
set_include_path($currIncPath . PATH_SEPARATOR . $path);
}
}
Last edited by misson; 01-10-2010 at 07:24 AM.
Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Jon Skeet's and Eric Raymond's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.Misson, not Mission.
Really helpfull misson, thks for the info
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
thanks for all the help. but how do you include a file that is not under /home/user/public_html. lets says i put it in /home/user/databse folder.how do i use php include to direct the file there?
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?
sorry i know thats a bit too many questions. im really new at this. hope you guys could help me out. thanks.
U can use relative path like inclued "/home/user/databse.php"
If you looking for more security u will have to begin from the first.Try using relative path it nust work
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
it doesnt work.
Sorry, i will give a try to solve it and if i get i will post you
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
I do believe that to be able to include a file not in the public_html folder (or one of its subfolders), you'll need to use absolute path.
Should be something like: /home/cpanelusername/path/to/script/script.php
Do you have trouble reaching your site?
Check here first: News and Announcements
Don't forget that x10hosting has a chat service as well. Come and join the fun
There's a lot helpful users there if need help building your site
Connect to our chat
I just tried using relative path and it just working fine... I dont know why you ends up with error
Regards ~ Vishal
Giving Reputation(at bottom of my post ) is the best way to encourage the person who helped you on forums.
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
Last edited by tillabong; 01-13-2010 at 09:28 AM.