我的代码中有这样的错误
致命错误:未捕获错误:调用未定义的函数 C:\ xampp \ htdocs \ wp \ server.php中的mysql_real_escape_string():12堆栈 trace:#0 C:\ xampp \ htdocs \ wp \ register.php(1):include()#1 {main} 在第12行的C:\ xampp \ htdocs \ wp \ server.php中抛出
我的代码是
$username="";
$email="";
$errors=array();
//conct to sever
$db = mysqli_connect('localhost','registration');
//register button click
if (isset($_POST['register'])){
$username=mysql_real_escape_string($conn,$_POST['username']);
$email=mysql_real_escape_string($conn,$_POST['email']);
$password_1=mysql_real_escape_string($_POST['password_1']);
$password_2=mysql_real_escape_string($_POST['password_2']);
有人可以解释一下php中mysql_real_escape_string()的功能是什么?
答案 0 :(得分:0)
由于你正在使用msqli,你应该使用mysqli函数:
$username = mysqli_real_escape_string($conn,$_POST['username']);