Mysql_real_escape_string () expectsparameter2toberesource, the objectgivenin code is as follows: & lt ;? Php {page_titleregister=include("header.html & quot;); # mysql_real_escape_string () expects parameter 2 to be resource, object given in
The code is as follows:
$ Page_title = 'register ';
Include ("header.html"); # webpage header
?>
If (isset ($ _ POST ['submitted']) {
Require_once ("mysqli_connect.php ");
$ Error = array (); # define the error as an array
If (empty ($ _ POST ['first _ name']) {
$ Error [] = 'You forgot to enter you first name ';
} Else {
$ Fn = mysql_real_escape_string (trim ($ _ POST ['first _ name']), $ dbc );
} # First name condition statement
If (empty ($ _ POST ['last _ name']) {
$ Error [] = 'You forgot to enter you last name ';
} Else {
$ Ln = mysql_real_escape_string (trim ($ _ POST ['last _ name']), $ dbc );
} # Last name condition statement
If (empty ($ _ POST ['email ']) {
$ Error [] = 'You forgot to enter you e-mail ';
} Else {
$ E = mysql_real_escape_string (trim ($ _ POST ['email ']), $ dbc );
} # Email condition statement
If (! Empty ($ _ POST ['password1 ']) {
If ($ _ POST ['password1 ']! = $ _ POST ['password2 ']) {
$ Error [] = 'Your password did not match the confirmed password .';
} Else {
$ P = mysql_real_escape_string (trim ($ _ POST ['password1 ']), $ dbc );
}
} Else {
$ Error [] = 'You forgot to your password ';
} # Password condition statement
If (empty ($ error )){
$ Q = "insert into users (first_name, last_name, email, pass, registration_date) VALUES ('$ fn', '$ ln', '$ E ', SHA1 ('$ P'), now ())";
[Email protected] _ query ($ dbc, $ q );
If ($ r ){
Echo 'Thank you!
You are now registered.
';
} Else {
Echo "system error
You cocould not bi registered due to a system error. We apolagize for any inconvenience. mysqli_error:. mysqli_error ($ dbc ).
Query:. $ q.
";
}
Mysqli_close ($ dbc );
Include('footer.html ');
Exit ();
} Else {
Echo "error!
The following error occurrde:
";
Foreach ($ error as $ key => $ msg ){
Echo "the error at $ key is $ msg
";
}
Echo"
Please try again
";
} # ERROR DISPLAY
}
?>
Register
Please do it
First_name:
Last_name:
Email Address:
Password: