Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Moderated Pro PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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.
Code:
<?php
// execute script only if form has been submitted
if (array_key_exists('register', $_POST)) {
// remove backslashes from the $_POST array
include('../includes/corefuncs.php');
include('../includes/connection.inc.php');
nukeMagicQuotes();
// 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’, 
‘$company_website’)";
$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";
}
}
}
?>
Thanks!





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





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