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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.