mysqli real escape string - 语法

mysqli_real_escape_string(connection,escapestring);

它函数转义SQL语句的字符串中的特殊字符。

Sr.No 参数 & Description
1

connection

它指定要使用的关于连接

2

escapestring

它指定有关未转义字符串的信息

mysqli real escape string - 返回值

它返回转义字符串。

mysqli real escape string - 示例

<?php
   $con=mysqli_connect("localhost","my_user","my_password","my_db");
   
   if (mysqli_connect_errno($con)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   $myName="Jr's";
   $myName=mysqli_real_escape_string($con,$myName);
   
   mysqli_query($con,"INSERT into emp (name) VALUES ('$myName')");
   mysqli_close($con);
?>

参考链接

https://www.learnfk.com/php/mysqli-real-escape-string.html