Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Moderated Pro PHP
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Moderated Pro PHP This is a moderated forum for discussing advanced, professional level issues with PHP. Your posts will not appear until a moderator approves them. Posts that are not the right level for this forum will be responded to and you'll be asked to post them in the [url="http://p2p.wrox.com/sql-server-2000-20/9"]Beginning PHP[/url] forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Moderated Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 14th, 2011, 10:48 PM
Registered User
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parse error: Syntax error, unexpected $end in....... at line.......

I tried using a code on a site, but I keep getting Parse error.... unexpected $end in line..... Ive done all I can, its not working. Can anybody help me? this is the code.
// execute script only if form has been submitted
if (array_key_exists('register', $_POST)) {
// remove backslashes from the $_POST array
// check length of username and password
$username = trim($_POST['username']);
$pwd = trim($_POST['pwd']);
// initialize message array
$message = array();
// check length of username
if (strlen($username) < 6) {
$message[] = 'Username must be at least 6 characters long';
// check password
if (strlen($pwd) < 8 || preg_match('/\s/', $pwd)) {
$message[] = 'Password must be at least 8 characters; no spaces';
// check that the passwords match
if ($pwd != $_POST['conf_pwd']) {
$message[] = 'Your passwords don\'t match';
// if no errors so far, check for duplicate username
if (!$message) {
// connect to database as administrator
$conn = dbConnect('admin');
$checkDuplicate = "SELECT user_id FROM users WHERE username = '$username'";// rest of code goes here
$result = $conn->query($checkDuplicate) or die(mysqli_error($conn));
$numRows = $result->num_rows;
if ($numRows) {
$message[] = "$username is already in use. Please choose another username.";
// otherwise, it's OK to insert the details in the database
else {
// create a salt using the current timestamp
$salt = time();
// encrypt the password and salt with SHA1
$pwd = sha1($pwd.$salt);
// insert details into database
$insert1= "INSERT INTO data_registration (company_name, company_address, city, state, postal_address, zip_code, country, mobile_number, e_mail, company_website)
VALUES (‘$company_name’, ‘$company_address’, ’$ city’, ‘$state’, ‘$postal_address’, ‘$zip_code’, ‘$country’, ‘$mobile_number’, ‘$e_mail’, 
$result1 = $conn->query($insert1) or die(mysqli_error($conn));
$insert2 = "INSERT INTO users (username, salt, pwd, security_queestion, answer)
VALUES ('$username', $salt, '$pwd', '$security’, ‘$answer’)";
$result2 = $conn->query($insert2) or die(mysqli_error($conn));

if ($result1 && $result2) {
$message[] = "Account created for $username";
else {
$message[] = "There was a problem creating an account for $username";
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
Parse error: parse error, unexpected $end Ayodeji Adegbaju Pro PHP 3 January 12th, 2007 12:21 PM

All times are GMT -4. The time now is 01:50 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.