这个问题已经有了答案:
mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?
1个答案
我在原型阶段,所以我在第一排有error_reporting(-1);。尽管如此,我没有php错误,但php打印“无法获取数据”。
正如我从php.net手册和stackoverflow类似案例中了解到的,我的$sorgula返回false。但为什么呢?你能帮忙吗,问候

//i am sure that i am connected to db
if ($sorgula = mysqli_query($dbc, "SELECT * FROM tb_yazilar ORDER BY kolon_sn"))
{
    while ($satir = mysqli_fetch_array($sorgula, MYSQLI_ASSOC))
    {
    echo $satir['kolon_yazar'].' - '.$satir['kolon_baslik'].' - '.$satir['kolon_yazi'].' - '.$satir['kolon_etiketler'].' - '.$satir['kolon_ytarihi'].' -  -  -  - ';
    }
}
else
{
echo 'could not get data';
}

mysqli_close($dbc);

最佳答案

尝试在代码中使用mysqli_error
程序示例:

$sorgula = mysqli_query($dbc, "SELECT * FROM tb_yazilar ORDER BY kolon_sn")
           or error_log(mysqli_error($dbc));

关于php - 为什么我不能使用mysqli_query从mysql db表中获取数据? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14715360/

10-10 21:49