php 的 mysql_real_escape_string 不起作用?

标签 php mysql mysql-real-escape-string

我的数据库中仍然没有转义“。这是我的代码:

$connection=mysql_connect ('localhost', $username, $password);

if (!$connection) {

  die('Not connected : ' . mysql_error());

}
$name = mysql_real_escape_string($name);
$address = mysql_real_escape_string($address);
$number = mysql_real_escape_string($number);
mysql_query("INSERT INTO people (name, area, phone)
VALUES ('$name', '$address', '$number')");

}

这里出了什么问题?

最佳答案

What's wrong here?

可能什么也没有。 mysql_real_escape_string() 仅在插入时转义字符串数据。数据一旦进入数据库就看起来没有变化,这就是它的本来面目。

您的代码看起来不错(除了您不是 checking the query for errors ,您想要这样做以便可以调试问题。)

关于php 的 mysql_real_escape_string 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8636566/

相关文章:

php - 如何避免 WordPress get_posts() 中自定义字段(元值)查询的 AND 条件数量限制?

php - 如何显示选择框中的选项?

php - HTML净化器Symfony2.3

php - 在 Laravel Blade 模板中截断字符串

php - $response JSON 只返回 1 行,PHP,ANDROID

php - 使用同一查询更新两行

python - 如何使用mysql在数据库端声明默认高精度日期时间default + onupdate

Mysql删除存储的转义字符

php - mysql real escape string - 这正常吗?