Jump to content

unexpected T_LNUMBER error.


leke

Recommended Posts

Hi, I can't figure out what I'm doing wrong because I don't understand why I'm getting...

 

Parse error: syntax error, unexpected T_LNUMBER in /home/leke/public_html/test/forum/registration_script.php on line 37

 

...which the php manual is to do with integers.

 

Line 37 is:

if ( ( strlen($username) < 2 || strlen($username) > 26 ) ) {

 

$username = $_POST['userName'];

// Wrong username length?
if ( ( strlen($username) < 2 || strlen($username) > 26 ) ) {
echo '<p class="fail">Username must be between 2-26 characters long.</p>';
exit;
}

 

Is there a problem on that line?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/245246-unexpected-t_lnumber-error/
Share on other sites

Hmm, I can't replicate that error using that code no matter what value I provide for $username - even if I use an explicit integer. Are you absolutely sure that is the right file and not some other file that is include()ed in that page? Go ahead and post the first 40 lines from registration_script.php

Here goes ;)

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<title></title>
</head>
<body>
<br />

<?php

$username = $_POST['userName'];
$password = $_POST['password'];

// Sanitise /////////////////////////////////////////

// Verify if captcha was entered correctly
if ($_SESSION['key'] == $_POST['verify']) {
// success continue the script.
} else {
echo '<p class="fail">Wrong captcha entered. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}

// Empty username input?
if ($username) {
// success continue the script.
} else {
echo '<p class="fail">You cannot submit empty userName. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}

// Wrong username length?
if ( ( strlen($username) < 2 || strlen($username) > 26 ) ) {
echo '<p class="fail">Username must be between 2-26 characters long. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}

// Empty password input?
if ($password) {
// success continue the script.
} else {
echo '<p class="fail">You cannot submit empty password. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}

// Wrong Password length?
if (strlen($password) < 5 || > strlen($password) 26) {
echo '<p class="fail">Password must be between 5-26 characters long. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}

// Same username and pssword?
if ($password == $userName {
echo '<p class="fail">Username and Password cannot match. <br />Use the browser\'s back button to correct your mistake.</p>';
exit;
}


// Connect to DB /////////////////////////////////////////////////////////
$conn = mysql_connect("localhost",  "admin", "password");
mysql_select_db("forum", $conn);
if (!$conn) {
    die('<p class="fail">Could not connect to DB: </p>' . mysql_error());
}
echo '<p class="success">Connected to DB successfully.</p>';

// INSERT data
$sql = "INSERT INTO login_table values ('$userName', SHA1('$password') )";
if (mysql_query($sql, $conn)) {
echo '<p>Registered as: ' . $username . '.<br />Click here to start using the forum.</p>'
} else {
echo '<p class="fail">Error: Failed to INSERT INTO MySQL.</p>';
}


?>

</body></html>

It reports the error now on line 51. I've been doing some editing to the file. Thanks.

This line:

 

if (strlen($password) < 5 || > strlen($password) 26) {

 

It should be strlen($password) > 26

 

And also this line:

 

if ($password == $userName {

 

You're missing a parenthesis.

Dang, I was reading the wrong line! Thanks also for spotting the other error :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.