HOME       >>       Programming

Located Url? PHP?


alex1985

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");


Galahad

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...

alex1985

Ok, that looks understandable. But, I got subdomain which is called: "mulhim". What should I do then?


alex1985

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.


rvalkass

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');


alex1985

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.


galexcd

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.

rvalkass

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.

alex1985

Ok, thanks. I will try it later on and then, post the answer. Sorry, I got final exams at my UNI to study.


alex1985

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.


VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.