Hello!
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: www.forensicoutreach.com/members.php. You will find on the website the error: Parse error: syntax error, unexpected T_REQUIRE in /websites/LinuxPackage02/fo/re/ns/forensicoutreach.com/public_html/members.php 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
require_once(‘includes/config.inc.php’);
include(‘includes/header.html’);
?>[/php]
In config.inc.php:
[php]<?php - config.inc.php
// Establish two constants for error reporting.
define(‘LIVE’, FALSE);
define(‘EMAIL’, ‘[email protected]’);
// Establish two constants for site-wide settings.
define(‘BASE_URL’, ‘http://www.forensicoutreach.com/’);
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');
?>[/php]
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’);
DEFINE (‘DB_PASSWORD’, ‘PASSWORD’);
DEFINE (‘DB_HOST’, ‘HOST’);
DEFINE (‘DB_NAME’, ‘DATABASE’);
// 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() );
}
?>[/php]
Can anyone see what’s wrong here? I am using PHP version 5.2.6 and additional information is at forensicoutreach.com/phpinfo.php.
Thanks very much for your help in advance!