Parse error: parse error in C:\wamp\www\test\register.php on line 54
which is on this line of code
PHP Code:
?>
Can anyone tell me why this error is occurring?
And/Or give me any other kind of advice on the script?
PHP Code:
<?php
ob_start();
include("conn.php");
function register($name , $email , $password , $password2){
//validate input
$sql="SELECT * FROM log_in WHERE email='" . $email . "'";//returns true if username already exists
//stripslashes and mysql_real_escape-string
$sInput= array(1=>$name ,$email ,$password ,$password2);
$x=1;
do{
$sInput[$x]=stripslashes($sInput[$x]);
$sInput[$x]=mysql_real_escape_string($sInput[$x]);
$x++;
}while($x<= 5);
//END stripslashes and mysql_real_escape_string
if((!$name) || (!$email) || (!$password) || (!$password2)){//if user didnt enter some field
$errors[]= "Please fill in all required fields.<br />";
}
if($password != $password2){//if password dont match
$errors[]= "The passwords must match.<br />";
}
if($sql){//if username exists
$errors[]= "That username already exists.<br />";
}
if(checkEmail($email)){}
else{ $errors[]="Email must be in the format of aa&aa.aaa .<br />";
if(strlen($password)<=5){//if passoword isnt atleast 5 characters
$errors[]= "Username must be atleast 5 characters long.<br />";
}
else if(strlen($password)>=33){//if password exceeds 32 characters
$errors[]= "Username cannot exceed 32 characters.<br />";
}
hey the error is just in the closing bracket of the Funtion:
it should be this:
PHP Code:
<?php
ob_start();
include("conn.php");
function register($name , $email , $password , $password2){
//validate input
$sql="SELECT * FROM log_in WHERE email='" . $email . "'";//returns true if username already exists
//stripslashes and mysql_real_escape-string
$sInput= array(1=>$name ,$email ,$password ,$password2);
$x=1;
do{
$sInput[$x]=stripslashes($sInput[$x]);
$sInput[$x]=mysql_real_escape_string($sInput[$x]);
$x++;
}while($x<= 5);
//END stripslashes and mysql_real_escape_string
if((!$name) || (!$email) || (!$password) || (!$password2)){//if user didnt enter some field
$errors[]= "Please fill in all required fields.<br />";
}
if($password != $password2){//if password dont match
$errors[]= "The passwords must match.<br />";
}
if($sql){//if username exists
$errors[]= "That username already exists.<br />";
}
if(checkEmail($email)){}
else{ $errors[]="Email must be in the format of aa&aa.aaa .<br />";}
if(strlen($password)<=5){//if passoword isnt atleast 5 characters
$errors[]= "Username must be atleast 5 characters long.<br />";
}
else if(strlen($password)>=33){//if password exceeds 32 characters
$errors[]= "Username cannot exceed 32 characters.<br />";
}
That way it will never loop more than the length of the array.
2. Deprecated means no longer considered part of the language, but still works on old versions. It won't work as of PHP 6, I believe.
3. Not sure about this one right off the top of the head.
Edit:could you mean sha1() instead? (There's no sha2() as far as I know)
Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
2. Deprecated means no longer considered part of the language, but still works on old versions. It won't work as of PHP 6, I believe.
Just an additional note, the ereg functions are deprecated as of 5.3.0 which was released 2009-06-30. And whizard is correct about them going away in PHP6: http://php.net/ereg.
I'm so happy to being a part of this large community of successful and future of great geeks found here!! I hope joining in this site would really help me and getting the best knowledge gigantically! Infect now a days i'm preparing for 642-061 exam for achieving the certification. Although it is not hard to get certified but it keeps me busy. I've also attained certification of another course of RH202 exam which I had passed last two months back. Also I am trying to complete my pending thesis of 000-973 exam project which i hope will be completed soon. I really enjoyed my stay over here and have knowledge while stopping by. And hope to hear from you folks!...