加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 使用预准备语句时“不允许属性访问”警告

发布时间:2020-12-13 13:21:21 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试使用AES_ENCRYPT()对我的密码进行编码来登录系统.但是在尝试实现这些代码时,我从xdebug得到了一些警告: ...$key = 'd0gis=SUPER-cute';$sql = "SELECT * FROM `users2` WHERE username = ? AND pwd = AES_ENCRYPT(?,?)";$stmt = $conn-stmt_init(
我正在尝试使用AES_ENCRYPT()对我的密码进行编码来登录系统.但是在尝试实现这些代码时,我从xdebug得到了一些警告:
...
$key = 'd0gis=SUPER-cute';
$sql = "SELECT * FROM `users2` WHERE username = ? AND pwd = AES_ENCRYPT(?,?)";
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param('sss',$username,$password,$key);
$stmt->execute();
$stmt->store_result();
...

当调试器遇到第8行或$stmt-> prepare($sql);时,来自xdebug的6个相同的警告表说:

(!) Warning: main(): Property access is not allowed yet in D:xampphtdocslearnphpincludesauthenticate_mysqli.inc.php on line 8

$stmt中的error属性为空,我没有真正的问题,但我只是想知道是什么原因导致出现此警告消息.

用Google搜索此警告消息但未找到任何解决方案:

> UPDATE query with prepared statements
> http://php.net/manual/en/mysqli-stmt.param-count.php

您的mysql连接可能尚未建立.在mysqli :: __ construct()之后你必须检查 mysqli::$connect_error,这对于某些PHP版本是破坏的:

The mysqli->connect_error property only works properly as of PHP versions 5.2.9 and 5.3.0. Use the mysqli_connect_error() function if compatibility with earlier PHP versions is required.

请参阅mysqli::__construct()文档中的连接锅炉板:

$mysqli = new mysqli('localhost','my_user','my_password','my_db');

/*
 * This is the "official" OO way to do it,* BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
 */
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

/*
 * Use this instead of $connect_error if you need to ensure
 * compatibility with PHP versions prior to 5.2.9 and 5.3.0.
 */
if (mysqli_connect_error()) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读