gpt4 book ai didi

Magento:默认 Adminhtml Controller 中的 PHP 警告

转载 作者:行者123 更新时间:2023-12-04 06:09:19 25 4
gpt4 key购买 nike

在调试 Magento 时,我发现了这个奇怪的警告。

警告:mysql_real_escape_string() [function.mysql-real-escape-string]:/mnt/www/t2/app/code/core/Mage/中的用户 'apache'@'localhost' 的访问被拒绝(使用密码:否)第 508 行的 Adminhtml/Controller/Action.php

在函数 checkforSqlInjectionInAction()

据我了解,当您无法打开与数据库的连接时,会出现此警告。但是在我的配置中,我没有使用本地服务器,因此我们无法连接到本地服务器是很自然的。

此警告位于 checkforSqlInjectionInAction() 中。

最佳答案

欢迎来到调试别人的 Magento 代码的美妙世界。 Magento 核心代码不包含名为 checkforSqlInjectionInAction 的方法。 ,因此您已经在处理由其他人的代码创建的核心 hack。

至于你的具体错误,mysql_real_escape_string将询问 MySQL 数据库正确的转义字符序列是什么。然而,这个函数被设计为与 PHP 的原始 MySQL 模块一起使用

The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.



由于 Magento 不使用 mysql_connect,PHP 尝试使用默认的 'apache'@'localhost' 创建连接。用户名,没有密码。

您应该使用原始 PDO 或读/写 Magento 连接资源来制作 SQL 语句。这些对象允许您使用绑定(bind)参数创建查询,而无需手动转义数据库字符串。

关于Magento:默认 Adminhtml Controller 中的 PHP 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7961114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com