mysql_escape_string():不推荐使用此函数; 请改用mysql_real_escape_string()

这是我面临的一个奇怪的问题,我的本地机器运行php 5.6.3而实时服务器正在运行php 5.4。 我们最近更新了我们的应用程序,从codeigniter 2. *到codeingiter 3.0,现在在实时服务器上运行时,我们开始了解这个全新的问题(较旧的问题,仍然没有工作 smtp )</ p>


遇到PHP错误</ p>

严重性:8192 </ p>

消息:mysql_escape_string():不推荐使用此函数; 改为使用mysql_real_escape_string()。</ p>

文件名:mysql / mysql_driver.php </ p>

行号:319 </ p>
</ blockquote> \ n

现在做了一些谷歌搜索,我发现顶级解决方案可能适用于ci 2. * 不起作用,因为codeigniter的 mysql_drivers.php </ code>文件已经在使用 mysql_real_escape_string()</ code>。 一个答案是建议我检查 database.php </ code>文件。 如果我的默认连接是 mysql </ code>而不是 mysqli </ code>,这是 mysqli </ code>,那么现在我无法找出出错的地方或者我是什么 我失踪了。</ p>
</ div>

展开原文

原文

This is some strange problem I'm facing, my local machine runs php 5.6.3 while live server is running php 5.4. We recently updated our app from codeigniter 2.* to codeingiter 3.0, now while running on live server we came to know about this brand new issue (older one and still not working smtp)

A PHP Error was encountered

Severity: 8192

Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

Filename: mysql/mysql_driver.php

Line Number: 319

Now after doing some googling, I found that top solution might be for ci 2.* doesn't work as codeigniter's mysql_drivers.php file is already using mysql_real_escape_string(). One answer is suggesting that I should check database.php file. If my default connection is mysql instead of mysqli which is mysqli, now I've no way to find out what is going wrong or what I'm missing.

dourukeng5302
dourukeng5302 考虑使用预准备语句,您不需要使用mysql_escape_string()或mysql_real_escape_string()
5 年多之前 回复

2个回答



PHP mysql </ code>驱动程序自5.5以来不推荐使用。
http://php.net/manual/en/intro.mysql.php </ p>

所以你最好不要使用它。 使用 mysqli </ code>。</ p>

mysql / mysql_driver.php </ code>上的第319行:
https://github.com/bcit-ci/CodeIgniter/blob/3fe79499c5bedb5b3bc4281821776f031f73674e/ system / database / drivers / mysql / mysql_driver.php#L319 </ p>

没有 mysql_escape_string()</ code>。 您似乎没有正确更新到3.0。</ p>
</ div>

展开原文

原文

PHP mysql driver is deprecated since 5.5. See http://php.net/manual/en/intro.mysql.php

So you better not use it. Use mysqli.

Line 319 on mysql/mysql_driver.php: https://github.com/bcit-ci/CodeIgniter/blob/3fe79499c5bedb5b3bc4281821776f031f73674e/system/database/drivers/mysql/mysql_driver.php#L319

There is no mysql_escape_string(). It seems you didn't update to 3.0 correctly.

duanboxue3422
duanboxue3422 你什么意思? 你的mysql / mysql_driver.php代码不同于3.0的代码,不是吗? 3.0的代码行319是注释* Rollback Transaction
5 年多之前 回复
dpbz14739
dpbz14739 是的,即使我看到了,但我不知道为什么它会抛出这个警告? 我在博客后彻底更新了CI
5 年多之前 回复



问题是你是冲突的</ strong> MySQL MySQLi </ p>

要解决您的问题,请使用 mysqli_real_escape_string()</ code> </ p>

您的知识的更多详细信息</ h2>

关于 mysql_escape_string()</ code> </ p>


警告:</ strong>

在PHP 4.3.0中不推荐使用此函数, 并将在未来删除,以及整个原始MySQL扩展。 相反,应该使用MySQLi或PDO_MySQL扩展。 另请参阅MySQL:选择API指南和相关的常见问题解答以获取更多信息。 此功能的替代方案包括:

mysqli_escape_string() </ code>

PDO :: quote( )</ code> </ p>
</ blockquote>

关于 mysql_real_escape_string()</ code> </ p>


警告:</ strong>

自PHP 5.5.0起,此扩展程序已弃用,将来将被删除。 相反,应该使用MySQLi或PDO_MySQL扩展。 另请参阅MySQL:选择API指南和相关的常见问题解答以获取更多信息。 此功能的替代方案包括:

mysqli_real_escape_string() </ code>

PDO :: quote( )</ code> </ p>
</ blockquote>
</ div>

展开原文

原文

And problem is you are conflicting MySQL and MySQLi

To solve your problem use mysqli_real_escape_string()

More Details to Your Knowledge

About mysql_escape_string()

Warning:
This function was deprecated in PHP 4.3.0, and will be removed in the future, along with the entirety of the original MySQL extension. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_escape_string()
PDO::quote()

About mysql_real_escape_string()

Warning:
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_real_escape_string()
PDO::quote()

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问