Moderated Pro PHPThis 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 .
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";
}
}
}
?>