leke Posted August 19, 2011 Share Posted August 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 19, 2011 Share Posted August 19, 2011 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 Quote Link to comment Share on other sites More sharing options...
leke Posted August 20, 2011 Author Share Posted August 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
Alex Posted August 20, 2011 Share Posted August 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
leke Posted August 20, 2011 Author Share Posted August 20, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.