I’m running XAMPP on win7 to test fairly simple sites using PHP/MySQL/AJAX, and have run into the problem of not being able to reference files correctly.
I know that C:\xampp\htdocs is “equivalent” to http://localhost/, and I have a project subdirectory in C:\xampp\htdocs\lorem_ipsum (which is http://localhost/lorem_ipsum/). Within that are some more folders (one for php scripts, one for css stylesheets, etc).
I’m having problems referencing files in these subdirectories.
For example, in lorem_ipsum/index.php I use the line:
require_once 'http://localhost/lorem_ipsum/php/login.php'
Which creates the error:
Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\lorem_ipsum\index.php on line 13
Warning: require_once(http://localhost/lorem_ipsum/php/login.php): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\lorem_ipsum\index.php on line 13
Fatal error: require_once(): Failed opening required 'http://localhost/lorem_ipsum/php/login.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\lorem_ipsum\index.php on line 13
By googling around I’ve gathered that it’s some sort of “filesharing/security” issue, but I have absolutely no idea what that means or how to fix it (I’m still very much a beginner).
When I use the following CSS, for example:
background-image:url('http://localhost/lorem_ipsum/images/bg.png')
The background is white, not ‘bg.png’. Same if I use './images/bg.png'.
I’ve tried all sorts of different ways to reference the files, and none have worked. I also tried taking down any firewalls and that didn’t work, either.
My ultimate question is: Why all the problems having to do with file references?
Secondary questions: Are the PHP and CSS errors related, or have I screwed them both up that badly? How can I stop this from happening? Is there a setting in apache/php that needs to change, or am I just coding it wrong?
In PHP, you should reference files from the Document_Root that is specified (C:\xampp\htdocs in your case). So try
The url in the css should work if the file is being hosted properly. But you can also try a relative path like: