Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql\u real\u escape\u字符串在PHP5.4.44中不起作用_Php_Mysql_Mysql Real Escape String_Php 5.4 - Fatal编程技术网

mysql\u real\u escape\u字符串在PHP5.4.44中不起作用

mysql\u real\u escape\u字符串在PHP5.4.44中不起作用,php,mysql,mysql-real-escape-string,php-5.4,Php,Mysql,Mysql Real Escape String,Php 5.4,我在我的网站上运行PHP版本5.4.44,并尝试使用mysql\u real\u escape\u字符串,但它没有给我任何东西。mysql\u real\u escape\u string在我的计算机上的localhost中工作正常。示例代码 <?php echo 'What is Your Name='.mysql_real_escape_string("my name is "); ?> It输出 你叫什么名字= mysql_real_escape_s

我在我的网站上运行PHP版本5.4.44,并尝试使用mysql\u real\u escape\u字符串,但它没有给我任何东西。
mysql\u real\u escape\u strin
g在我的计算机上的localhost中工作正常。示例代码

 <?php
    echo 'What is Your Name='.mysql_real_escape_string("my name is ");
    ?> 

It输出

你叫什么名字=

mysql_real_escape_string-为一个字符串中的特殊字符进行转义 在SQL语句中使用

在向MySQL发送查询之前,必须始终使用此函数(很少有例外)确保数据安全

因此,在使用
mysql\u real\u escape\u string

$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
    OR die(mysql_error());

   echo 'What is Your Name='.mysql_real_escape_string("my name is ");
输出

你叫什么名字

已更新


根据我们的讨论,您正在使用mysqli,因此您在代码中混合了mysql和mysqli

mysqli_real_escape_string($con,("my name is 'kk/'");//pass first parameter your database connection

数据库连接成功吗?您是否看到任何错误或警告

如果在本地主机上工作正常,请检查用于连接到服务器的连接字符串


另外,PHP 5.5.0中不推荐使用函数
mysql\u real\u escape\u string
。您可能想看看@Saty include(“define.php”);$con=mysqli\u connect(DB\u服务器、DB\u用户、DB\u通行证、DB\u名称);如果(mysqli_connect_errno()){echo”无法连接到MySQL:“.mysqli_connect_error();}否则{echo'您的名字是什么='。MySQL_real_escape_string(“我的名字是'kk/');}在代码中混合使用MySQL和mysqli。两者都不同。使用mysql或mysqlii am use mysqli for connect并尝试mysql_real_escape_string和mysqli_real_escape_string都不起作用@Saty
mysqli_real_escape_string($con,(“我的名字是‘kk/”);
传递第一个参数$con变量
echo‘你的名字是什么’。mysql_real_escape_字符串(“我的名字是”)
-这行没有意义。