【问题标题】:What is the function of mysql_real_escape_string() in php?php中mysql_real_escape_string()的作用是什么?
【发布时间】:2018-06-03 06:23:37
【问题描述】:

我的代码中有这样的错误

致命错误:未捕获错误:调用未定义函数 C:\xampp\htdocs\wp\server.php:12 中的 mysql_real_escape_string() 堆栈 跟踪:#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()的作用是什么?

【问题讨论】:

标签: php html login system


【解决方案1】:

由于你使用的是 msqli,所以你应该使用 mysqli 函数:

$username = mysqli_real_escape_string($conn,$_POST['username']);

【讨论】:

  • 真的,你不应该再使用准备好的状态和绑定参数了
猜你喜欢
  • 2010-10-06
  • 2010-10-06
  • 2012-02-29
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 2014-06-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多