PHP path not working right

I am using XAMPP, and my application is installed at my C:\xampp\htdocs\photos, where ‘photos’ is the name of my application. For security purposes, I have decided that documents accessible to the public will be at C:\xampp\htdocs\photos\public, while I put files I do not want the public to access at C:\xampp\htdocs\photos\includes.

So when I run http://localhost/photos/public, it runs the default file index.php. The very first line in this file is:
[php]require_once(’…\includes\initialize.php’); // This works just fine and is able to load initialize.php[/php]

But inside the file “initialize.php” is where my problem occurs. Here is the actual code within initialize.php:

[php]defined(‘DS’) ? null : define(‘DS’, DIRECTORY_SEPARATOR);
defined(‘SITE_ROOT’) ? null : define(‘SITE_ROOT’, DS.‘photos’);
defined(‘LIB_PATH’) ? null : define(‘LIB_PATH’, SITE_ROOT.DS.‘includes’);

echo LIB_PATH.DS.‘functions.php’; // prints out \photos\includes\functions.php, which is correct

// This line is getting the error “No such file or directory” because the file does exist, and I don’t understand why.
require_once(LIB_PATH.DS.‘functions.php’);[/php]

I’m just starting PHP, and I can’t believe I’m getting bogged down on a problem like this. I would be grateful to anyone who could help me. Thanks!

Take a look at this thread…

http://www.phphelp.com/forum/beginners-learning-php/setting-proper-relative-paths/

Sponsor our Newsletter | Privacy Policy | Terms of Service