warning:mysql_fetch_array()期望参数1为资源,对象为[duplicate]

问题描述 投票:12回答:3
嗨,我在尝试运行此代码时收到上述警告:

$mysqli=new mysqli("localhost", "***", "***","***") or die(mysql_error()); function checklogin($username, $password){ global $mysqli; $result = $mysqli->prepare("SELECT * FROM users WHERE username = ?"); $result->bind_param("s", $username); $result->execute(); if($result != false){ $dbArray=mysql_fetch_array($result);

php mysqli prepared-statement
3个回答
43
投票
您在代码中混合了mysql和mysqli调用。使用mysqli_fetch_array代替mysql_fetch_array

7
投票
您正在混合mysqli和传统mysql命令。

使用$result->fetch_array()


1
投票
您正在使用两组不同的函数... mysqli和mysql。我认为您想使用fetch_assoc()方法。

签出$result->fetch_array()


0
投票

我只是犯了同样的错误,但是当我将其更改为mysqli_fetch_array()时,它解决了。

© www.soinside.com 2019 - 2024. All rights reserved.