I get error with the preg_match on line 56, I also get errors on line

include_once “functions.php”;

connect()

if(!$_POST[‘submit’]){
echo “<table border=“0” cellspacing=“3” cellpadding"3”>\n";
echo “<form method=“post” action=“register.php”>\n”;
echo “

<td colspan=“2” align=“center”>registration Forum\n”;
echo “ Username <input type=“text” name=“username”> \n”;
echo “ Password <input type=“password” name=“password”> \n”;
echo “ Confirm <input type=“password” name=“passconf”> \n”;
echo “ Email <input type=“text” name=“email”> \n”;
echo “<td colspan=“2” align=“center”><input type=“submit” name=“submit” value=“Register”>\n”;
echo “\n”;
}else {
$username = protect($_POST[‘username’]);
$password = protect($_POST[‘password’]);
$confirm = protect($_POST[‘passconf’]);
$email = protect($_POST[‘email’]);
$error = array();

	if(!$username){
		!$errors[] = "Username is not defined!";
	}
	
	if(!$password){
		!$errors[] = "Password is not defined!";
	}
	
	if(!$password){
		if(!$confirm) {
			!$errors[] = "Confirm passowrd is not defined!";
		}
	}
	
	if(!$email){
		!$errors[] = "E-mail is not defined!";
	}
	
	if($username){
		if(!ctype_alnum($username)){
			$errors[] = "Username can only contains letters and numbers!";
		}
		
	}
	
	if($password && confirm){
		if($password != $confirm){
			$errors[] = "Passwords do not match!";
		}
	}
	
	if($email){
		$checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)@([a-z0-9]+([/.-][a-z0-9]+)*)+\\.[a-z](2,)$/i";
		if (!preg_match($email, $checkemail)){
			$errors[] = "E-mail is not valid, [email protected]!";
		}
	}
	
	if($username){
		$sql = "SELECT * FROM 'Users' WHERE 'username' = '($username)'";
		$res = mysql_query($sql) or die(mysql_error);
		
			if(mysql_num_rows($res) > 0){
				$errors[] = "The username you have entered is already taken!";
			}
	}
	
	if($email){
		$sql2 = "SELECT * FROM 'Users' WHERE 'email'='($email)'";
		$res2 = mysql_query($sql2) or die(mysql_error());
		
			if(mysql_num_rows($res2) > 0){
				$errors[] = "This email is already in use!";
			}
	}
	
	if(count($errors) > 0){
		foreach($errors AS $error){
			echo error . "<br>\n";
		
		}
	}else{
		$sql3 = "INSERT INTO 'Users'
				('username', 'password', 'email')
				VALUES ('$username', '".md5($password)."', '$email');";
		$res4 = mysql_query($sql3) or die(mysql_error());
		echo "You have successfully registered '<b>($username)</b>'";
		}
	}

?>

Another problem, where I put connect() I get an error saying it can’t connect.

that’s the website link if you want to test it.

is connect() part of the code? if so it should end in a semi colon ;

If not, can you put [php] tags around the code.

RaythXC is correct you omitted a semicolon.

connect() or correctly connect(); calls another php function oddly enough called connect(). If adding the semicolon does not solve your problem, providing the code for the function connect() can help us, help you.

You might want to consult your PHP error logs. There you would have seen a fatal error on that line. PHP has no error reporting other than through the logs. I keep my console open when developing. Just because your code actually runs, doest mean there’s nothing funky in your code. You might be amazed at the number of warnings that are logged…

Sponsor our Newsletter | Privacy Policy | Terms of Service