Parse Error In Relation to Require_Once -- Cannot Detect Problem


I’m building a website for a small business and have tried to adapt the scripts in Chapter 16 to create a “members/users” area through which they can access otherwise locked resources. The log-in page can be found here: You will find on the website the error: Parse error: syntax error, unexpected T_REQUIRE in /websites/LinuxPackage02/fo/re/ns/ on line 3.

However, I cannot locate anything wrong with any of the included files or the functions I am using. In members.php (analogous to index.php in the book):

[php]<?php - index.php





[php]<?php -

// Establish two constants for error reporting.

define(‘LIVE’, FALSE);

define(‘EMAIL’, ‘[email protected]’);

// Establish two constants for site-wide settings.

define(‘BASE_URL’, ‘’);

define (‘MYSQL’, ‘mysqli_connect.php’);

// Establish other site-wide settings.

date_default_timezone_set (‘Europe/London’);

// Begin defining the error-handling function.

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

An error occurred in script ‘$e file’ on line $e_line: $e_message\n

    $message .= "Date/Time:" . date('n-j-Y H:i:s') . "\n<br />";
    $message .= "<pre>" . print_r($e_vars, 1) . "</pre>\n</p>";

// Handle the error according to the value of LIVE.

if (!LIVE) {

    echo '<div class="error">' . $message . '</div><br />';

} else {

    mail(EMAIL, 'Site Error!', $message, 'From: [email protected]');
    if ($e_number != E_NOTICE) {
            echo '<div class="error">A system error occurred. We apologise for the inconvenience. </div><br />';


    } set_error_handler ('my_error_handler');

And finally, in mysqli_connect (with host/password/database removed):

[php]<?php - mysqli_connect.php

// This file contains the database access information.
// This file also establishes a connection to MySQL
// and selects the database.

// Set the database access information as constants:
DEFINE (‘DB_USER’, ‘ufor_250520_0003’);

// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

if (!$dbc) {
trigger_error ('Could not connect to MySQL: ’ . mysqli_connect_error() );


Can anyone see what’s wrong here? I am using PHP version 5.2.6 and additional information is at

Thanks very much for your help in advance!

The first line of your every script what you posted here looks like this:
[php]<?php - index.php[/php]

Do you really have this -index.php in your code? If yes, you need to either remove this, or comment it. This will be correct:
[php]<?php // index.php[/php]

im not sure if this will cause an error but you have a typo here:
[php]$message = “

An error occurred in script ‘$e file’ on line $e_line: $e_message\n
notice the underscore _ is missing from $e_file…

let me know if that fixes it…

Thank you PHP Coder and Redscouse; indeed it was the lack of commenting out the names of the scripts.

(Redcouse, I think for some reason the underscore did not show up on the post but I double-checked and it was there – strange!)

I really do appreciate your help; haven’t been able to get a straight answer from anyone else on the web believe it or not, so I will definitely be a regular on these boards from now on. Thanks!

i did see the file names but as PHPCoder had offered correct advice i wasn’t going to comment, then i spotted the typo so i thought i’d point it out.

Glad you got it working :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service