Mysql_real_escape_string () expects parameter 2 to being resource, object given in, how to fix

Source: Internet
Author: User
Mysql_real_escape_string () expects parameter 2 to BES resource, object given in
The code is as follows:

$page _title = ' Register ';
Include ("header.html"); #网页头部
?>


if (Isset ($_post[' submitted ')) {
Require_once ("mysqli_connect.php");

$error =array (); #定义错误为数组
if (Empty ($_post[' first_name ')) {
$error []= ' forgot to enter your first name ';
}else{
$FN = mysql_real_escape_string (Trim ($_post[' first_name '), $DBC);
} #first the name condition statement

if (Empty ($_post[' last_name ')) {
$error []= ' forgot to enter your last name ';
}else{
$LN = mysql_real_escape_string (Trim ($_post[' last_name '), $DBC);
} #last the name condition statement

if (Empty ($_post[' email ')) {
$error []= ' forgot to enter your email ';
}else{
$e = mysql_real_escape_string (Trim ($_post[' email '), $DBC);
} # Email Conditional 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 []= ' forgot to your password ';
} # Password Conditional statement


if (empty ($error)) {

$q = "INSERT into users (first_name, last_name, e-mail, pass,registration_date) VALUES (' $fn ', ' $ln ', ' $e ', SHA1 (' $p '), now () )";
[Email Protected]_query ($DBC, $q);
if ($r) {
Echo '

Thank you!


You is now registered.

';
}else{
echo "

System error


You could 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

";
} #错误显示


}
?>




Register



Please do it

First_Name:


Last_Name:


Email Address:


Password:

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.