Heim  >  Artikel  >  Backend-Entwicklung  >  mysql_real_escape_string() expects parameter 2 to be resource, object given in,该怎么解决

mysql_real_escape_string() expects parameter 2 to be resource, object given in,该怎么解决

WBOY
WBOYOriginal
2016-06-13 13:30:57938Durchsuche

mysql_real_escape_string() expects parameter 2 to be resource, object given in
代码如下:

$page_title = 'Register ';
include("header.html"); #网页头部
?>


if(isset($_POST['submitted'])){
require_once("mysqli_connect.php");
 
$error=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 条件语句
 
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 条件语句
 
if (empty($_POST['email'])){
$error[]='you forgot to enter you email';
}else{
$e= mysql_real_escape_string(trim($_POST['email']),$dbc);
} # email 条件语句
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 条件语句  


if(empty($error)){

$q="INSERT INTO users (first_name, last_name, email, pass,registration_date) VALUES ('$fn','$ln','$e',SHA1('$p'),now())";
$r=@mysqli_query ($dbc ,$q);
if($r){
echo '

Thank you !


you are 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:

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel: PHP上传有关问题 Nächster Artikel: 使用php将excel转HTML解决办法