I keep getting this error but I have checked all of the brackets and they seem ok. I don't know what to do now. I would appreciate some ideas.
Here is the code:
<?php
//this script registers a new user.
require_once 'dBconnect.php';
require_once 'functions.php';
if (isset($_POST['register'])) { //if the form has been submitted
$userName = $_POST['user'];
$pass = $_POST['pass'];
$rePass = $_POST['rePass'];
$query = 'SELECT * FROM users WHERE user_id="$userName"';
$insertUser = 'INSERT INTO users VALUES ($userName, $pass)';
$errors[] = '';
if (empty($userName) || empty($pass) || empty($rePass)) { //are any of the fields empty
$errors += 'All fields must be filled out.';}
elseif ($pass != $rePass) { //all fileds are filled out, are the values valid?
$errors += 'The passwords do not match.';}
elseif (strlen($pass) < 4 || strlen($pass) > 12) { //check if username is too long or too short
$errors += 'You password must be between 4 and 12 characters long.';}
elseif (strlen($userName) < 4 || strlen($userName) > 12) { //check if username is too long or too short
$errors += 'You username must be between 4 and 12 characters long.';}
elseif (preg_replace('/[\w ]/', '', $userName) { //check for invalid characters in the username
$errors += 'Your username may only contain letters, numbers, or underscores';}
else { //check if username already exists
$result = mysql_query($query) or die('Connection Error.');
if (mysql_num_rows($result) > 0) {
$errors += 'That username is already taken.';}
else { //add user to the database
mysql_query($insertUser) or die('Connection Error.');
echo 'You have been added! sign-in and enjoy.'; }
}
} else { //show form and errors if applicable
showRegisterForm($errors);
}
?>