Artemis Posted April 4, 2011 Share Posted April 4, 2011 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 - index.php require_once('includes/config.inc.php'); include('includes/header.html'); ?> In config.in.php: <?php - config.inc.php // Establish two constants for error reporting. define('LIVE', FALSE); define('EMAIL', 'myemail@hotmail.com'); // 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 = "<p>An error occurred in script '$e file' on line $e_line: $e_message\n<br />"; $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@example.com'); 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 - 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() ); } ?> 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! Link to comment Share on other sites More sharing options...
Jonathon Posted April 4, 2011 Share Posted April 4, 2011 Hello Shivani, Try this: <?php // index.php require_once('includes/config.inc.php'); include('includes/header.html'); ?> 1 Link to comment Share on other sites More sharing options...
Jonathon Posted April 4, 2011 Share Posted April 4, 2011 That probably won't help you, my mistake, what is your code for members.php? 1 Link to comment Share on other sites More sharing options...
Stuart Posted April 4, 2011 Share Posted April 4, 2011 Like Jonathon says you'll need to post the code for members.php but equally his first suggestion did pick up on a problem. The lines: <?php - index.php <?php - mysqli_connect.php <?php - config.inc.php would cause a syntax error. 1 Link to comment Share on other sites More sharing options...
Artemis Posted April 5, 2011 Author Share Posted April 5, 2011 Hi Stuart! Yes that was the problem. Sometimes the obvious isn't! Many thanks to both of you for your responses. Link to comment Share on other sites More sharing options...
Recommended Posts