Jump to content
xisto Community
alex1985

Located Url? PHP?

Recommended Posts

I did the configuration file for my web-site but there is a mistake, it can find the path to that configuration file.

Could you give me the proper way to set a correct path to the configuration file.

This is what I did actually based on the used tutorial.


require_once ("/mulhim.outlaw.trap17.com/library_project/test_dir/test1/config.php");

Share this post


Link to post
Share on other sites

I suppose your website address here on Xisto is mulhim.outlaw.trap17.com? If it is, you can change the following line

require_once ("/mulhim.outlaw.trap17.com/library_project/test_dir/test1/config.php");
to
require_once ("library_project/test_dir/test1/config.php");

And that should fix your problem... What you tried earlier, is to tll PHP to look for a configuration file in directory mulhim.outlaw.trap17.com then library_project subdirectory, etc... You don't have to specify your own domain in require... Hope this solves your problem...

Share this post


Link to post
Share on other sites

Which directory is the script being run from, as the path needs to be relative to that location. For example, if the script is in /public_html/mulhim/library_project/ then you would just need this as your code:

require_once('test_dir/test1/config.php');

Share this post


Link to post
Share on other sites

I will try it tomorrows, and then post the answer if it's working or not, it's too late now. I hope it will.You are definitely right, the script which I want to initiate is located in test1 folder, but there is admin folder inside the test1 folder and the page that adds entries to database like add.php is located inside the admin folder.So, add.php has that function (require_once) in ...test1/admin/add.php location that has to find the config.php in ...test1/config.php. That's why I need the proper code or location for the url.I did not tried the previous post, as I said I will do it tomorrow. So, I did explain in detail.Thanks.

Share this post


Link to post
Share on other sites

I did it just now, and it does not work. I tried: "mulhim/library_project/test_dir/test1/config.php" and "mulhim.library_project/test_dir/test1/config.php"
Any more suggestions.


Like true-fusion said, you are not in the web-root directory like your mulhim folder is, and when you type a forward slash at the beginning, php automatically goes to the first root, not the web root. You could try either "/www/mulhim/library_project/test_dir/test1/config.php" or something like "/home/outlaw/www/mulhim/library_project/test_dir/test1/config.php". you need to figure out the path to your web root, and then stick "mulhim/library_project/test_dir/test1/config.php" behind it.

Share this post


Link to post
Share on other sites

As alex7h3pr0gr4m3r has said, starting the path with a / makes PHP start from the root directory rather than your current location. The easiest way to do it will be the following:

 

require_once('../config.php');

The ../ tells PHP to move up to the parent directory, which is where it can find the config.php file.

Share this post


Link to post
Share on other sites

As alex7h3pr0gr4m3r has said, starting the path with a / makes PHP start from the root directory rather than your current location. The easiest way to do it will be the following:

 

require_once('../config.php');

The ../ tells PHP to move up to the parent directory, which is where it can find the config.php file.

Thanks. This reply helped me. It does work now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.