mysql_real_escape_string未定义 [英] mysql_real_escape_string is undefined
问题描述
我正在使用PHP版本5.3,并尝试在代码中使用mysql_real_escape_string($unescaped_string)
,但出现错误:
I am using PHP version 5.3 and trying to use mysql_real_escape_string($unescaped_string)
in my code, but I get the error:
Fatal error: Call to undefined function mysql_real_escape_string()
in /var/www/engine/database.php on line 38
但是我仍然可以连接到数据库.为什么不可用?
I can still connect to the database however. Why is it not available?
我正在使用PHP 5.3版.
I am using PHP version 5.3.
推荐答案
更新,如自5.5起弃用:
自PHP 5.5起不推荐使用mysql扩展名.应该使用mysqli或PDO扩展名.在 mysql_deprecation 中已决定弃用,在此可以找到对该决定背后原因的讨论.
The mysql extension has been deprecated since PHP 5.5. The mysqli or PDO extension should be used instead. The deprecation has been decided in mysql_deprecation, where a discussion of the reasons behind this decision can be found.
和在PHP 7中已删除.
mysql_real_escape_string()
是 MySQL函数"batch" 的标准部分,如果扩展名正确加载,始终可以工作.
mysql_real_escape_string()
is standard part of MySQL function "batch" and should always work if the extension is loaded correctly.
是否还有其他mysql_
功能正常工作? (不应该)
Does any another mysql_
function work? (It should not)
请确保您在php.ini
中未注释此行:
Make sure, that you have this line uncommented in your php.ini
:
extension=mysql.so
Also it'd be wise to use mysqli
or PDO
instead (mysql_
is deprecated), they both can take care of escaping for you.
这篇关于mysql_real_escape_string未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!