3

I am trying to figure why I am getting this error.

**Warning: require_once(\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\config.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\initialize.php on line 16

Fatal error: require_once() [function.require]: Failed opening required '\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\config.php' (include_path='.;C:\php5\pear') in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\initialize.php on line 16**

Now here is the code in the index.php page

<?php
require_once('../../includes/initialize.php');

if (!$session->is_logged_in()) { redirect_to("login.php"); }
?>
<?php include_layout_template('admin_header.php'); ?>
  <h2>Menu</h2>

  </div>


<?php include_layout_template('admin_footer.php'); ?>

Here is the code for the initialize.php page:

<?php

// Define the core paths
// Define them as absolute paths to make sure that require_once works as expected

// DIRECTORY_SEPARATOR is a PHP pre-defined constant
// (\ for Windows, / for Unix)
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT') ? null : 
 define('SITE_ROOT', DS.'C'.DS.'wamp'.DS.'www'.DS.'PHP with MySQL Beyond the Basics'.DS.'Chapter06'.DS.'06_12_photo_gallery');

defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');

// load config file first
require_once(LIB_PATH.DS.'config.php');

// load basic functions next so that everything after can use them
require_once(LIB_PATH.DS.'functions.php');

// load core objects
require_once(LIB_PATH.DS.'session.php');
require_once(LIB_PATH.DS.'database.php');

// load database-related classes
require_once(LIB_PATH.DS.'user.php');

?>
Amen Ra
  • 2,843
  • 8
  • 47
  • 85

2 Answers2

3

I don't think this is a directory separator problem: You can use both forward and backward slashes on Windows.

The problem is here:

\C\wamp\www\PHP with MySQL Beyond the Basics

unless you have a directory named C in the root path on the current drive, what you really want is

C:\wamp\www\PHP with MySQL Beyond the Basics
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

I think here is how it works for mw

defined('SITE_ROOT') ? null : 
define('SITE_ROOT', 'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery');
Sam
  • 11
  • 3