Jump to content



Photo

Chapter 3 Error Message


  • Please log in to reply
3 replies to this topic

#1 e-mazed

e-mazed

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 4 February 2012 - 8:29 PM

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:
require('/html/includes/config.inc.php');

My config.php file isn't giving me any code errors and looks like this:
<?php
$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:
session_start();

// ************ 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');
  • 0

#2 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,119 posts

Posted 5 February 2012 - 8:44 AM

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

#3 e-mazed

e-mazed

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 5 February 2012 - 10:54 AM

Thanks Edward

I can't believe it was such a rookie mistake.. i ended up using the code hint in DW and it fixed the entire problem... thxs a million!!
  • 1

#4 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 1,119 posts

Posted 5 February 2012 - 11:09 AM

Excellent, i also have the DW IDE, its awesome. Don't worry about the silly mistakes i tripped up on a few of these issues myself.
  • 0