Jump to content
Larry Ullman's Book Forums

Login.Inc.Php: (Chapter 4) Unexpected T_String

Recommended Posts

on the brink of New Year with one last question before 2013....


Parse error: syntax error, unexpected T_STRING in /hermes/waloraweb004/b1384/moo.laissezfairelondonco/wolfcut/includes/login.inc.php on line 27


This is really obvious (sytax error), not so, because I have been through each line over 10 times; compared it to the code in the Ecommerce book and copied / paste from the downloaded code. So I can't see where I have left out a bracket or a semi-colon.


Here's the code for login.inc.php from example one:






$login_errors = array();


if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {

$e = mysqli_real_escape_string ($dbc, $_POST['email']);


} else {


$login_errors['email'] = 'Please enter a valid email address!';



// Validate the password:

if (!empty($_POST['pass'])) {

$p = mysqli_real_escape_string ($dbc, $_POST['pass']);

} else {

$login_errors['pass'] = 'Please enter your password!';



if (empty($login_errors)) { // OK to proceed!


// Query the database and is line 27 where syntax error is supposed to be

$q = "SELECT id, username, type, IF(date_expires >= NOW(), true, false) FROM users WHERE (email='$e' AND pass='" SHA1($p) "')";

$r = mysqli_query ($dbc, $q);


if (mysqli_num_rows($r) == 1) { // A match was made.


// Get the data:

$row = mysqli_fetch_array ($r, MYSQLI_NUM);


// If the user is an administrator, create a new session ID to be safe:


// This code is created at the end of Chapter 4:

if ($row[2] == 'admin') {


$_SESSION['user_admin'] = true;



// Store the data in a session:

$_SESSION['user_id'] = $row[0];

$_SESSION['username'] = $row[1];


// Only indicate if the user's account is not expired:

if ($row[3] == 1) $_SESSION['user_not_expired'] = true;


} else { // No match was made.

$login_errors['login'] = 'The email address and password do not match those on file.';



} // End of $login_errors IF.

// Omit the closing PHP tag to avoid 'headers already sent' errors!

Link to comment
Share on other sites

Thanks Larry!


I mean it. Thank you for dedicating so much time on the forums for everyone, and the great books on the subject. It's going to help a lot of people get ahead and become self-sufficient.


Best wishes to you and all the advisers on these forums - really, if anyone is listening, where else can complete strangers get help like this from other complete strangers in such a way.....

Link to comment
Share on other sites


  • Create New...