警告:mysqli_fetch_assoc()期望参数1为mysqli_result,字符串在 [英] Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in

查看:320
本文介绍了警告:mysqli_fetch_assoc()期望参数1为mysqli_result,字符串在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图获取表中的最后一行,但抛出错误...

Trying to get the last row in the table but throwing error ...

'警告:mysqli_fetch_assoc()期望参数1为 mysqli_result,在'

'Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in '

$recents = "SELECT * FROM list ORDER BY id DESC LIMIT 1";
if ($result = mysqli_fetch_assoc($recents)) {
    $mName = $result['name'];
    $mDesc = $result['description'];
    $mCost = $result['cost'];
}

推荐答案

您需要传递查询的结果,而不是查询字符串.

You need to pass a result from a query, not the query string.

$sql = "SELECT * FROM list ORDER BY id DESC LIMIT 1";
$recent = mysqli_query($connetion, $sql);

这篇关于警告:mysqli_fetch_assoc()期望参数1为mysqli_result,字符串在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆