Jump to content
Larry Ullman's Book Forums

Chapter 3 Error Message

Recommended Posts

Hi All,


I have gone over my code a number of times and i am stumbled why this is not working. I am using DW CS5 to run the code. When I go to live view for my index.php I get the following error:

Warning: require(/html/includes/config.inc.php) [function.require]: failed to open stream: No such file or directory in/Applications/MAMP/htdocs/html/includes/index.php on line 7


Fatal error: require() [function.require]: Failed opening required '/html/includes/config.inc.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in/Applications/MAMP/htdocs/html/includes/index.php on line 7


My line 7 of my code is the require connection to my config.php and looks like this:



My config.php file isn't giving me any code errors and looks like this:


$live = false;

$contact_email = 'info@e-mazed.com';

define ('BASE_URI', 'file:///Macintosh HD/Users/macuser/Applications/MAMP/htdocs/html');

define ('BASE_URL', 'localhost/html');

define ('MYSQL', 'mysql.inc.php');


// ************ CONSTANTS *********** //

// ********************************** //


// ********************************* //

// ************ SESSIONS *********** //


// Start the session:



// ************ SESSIONS *********** //

// ********************************* //


// ****************************************** //

// ************ ERROR MANAGEMENT ************ //


// Function for handling errors.

// Takes five arguments: error number, error message (string), name of the file where the error occurred (string)

// line number where the error occurred, and the variables that existed at the time (array).

// Returns true.

function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {


// Need these two vars:

global $live, $contact_email;


// Build the error message:

$message = "An error occurred in script '$e_file' on line $e_line:\n$e_message\n";


// Add the backtrace:

$message .= "<pre>" .print_r(debug_backtrace(), 1) . "</pre>\n";


// Or just append $e_vars to the message:

// $message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n";


if (!$live) { // Show the error in the browser.


echo '<div class="error">' . nl2br($message) . '</div>';


} else { // Development (print the error).


// Send the error in an email:

error_log ($message, 1, $contact_email, 'From:admin@example.com');


// Only print an error message in the browser, if the error isn't a notice:

if ($e_number != E_NOTICE) {

echo '<div class="error">A system error occurred. We apologize for the inconvenience.</div>';



} // End of $live IF-ELSE.


return true; // So that PHP doesn't try to handle the error, too.


} // End of my_error_handler() definition.


// Use my error handler:

set_error_handler ('my_error_handler');

Link to comment
Share on other sites

Well this is error is indicating that the index.php require is not locating the config.inc.php file at that location, and therefore your receiving the Fatal error.


Your index.php file should be below the includes directory and in your html root directory.


require ('./includes/config.inc.php'); I am using XAMMP and this is my location of config.inc.php


This should be a simple case of just tiding up file locations and moving files.

  • Upvote 1
Link to comment
Share on other sites


  • Create New...