php 遇到报错 Call to a member function fetch_object()

Posted feiyun8616的作坊 (半个程序员and dba)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 遇到报错 Call to a member function fetch_object()相关的知识,希望对你有一定的参考价值。

 

1.检查语法 ,没问题

<?php
require "fun.php";
$kc_sql="select distinct KCM from KCB"; //查找课程名
$conn= new mysqli(‘localhost‘,‘root‘,‘‘,‘PXSCJ2‘);
$kc_result=mysqli_query($conn,$kc_sql); ///* Select queries return a resultset */
//var_dump($kc_result);
while ($kc_row= $kc_result->fetch_array(MYSQLI_ASSOC)) // * fetch array */
{
echo "<option>".$kc_row[‘KCM‘]."</option>"; //输出课程名到下拉框中
}
?>

 

 

2.使用 var_dump 输出,没有结果

var_dump($kc_result);

 

3.直接在mysqladmin 里查询,结果

select distinct KCM from KCB" 

 

提示报错,检查发现字段名字是中文的,改成英文的,就可以了。

 












以上是关于php 遇到报错 Call to a member function fetch_object()的主要内容,如果未能解决你的问题,请参考以下文章

关于“Call to a member function display() on a non-object”的解决方案

laravel Call to a member function addEagerConstraints() on null

2023-04-14 Fatal error: Call to a member function fetch_assoc() on a non-object in C:wampwwwworkuser

Fatal error: Call to a member function read() on a non

PHP Fatal error: Call to a member function query() on a non-object in F 代码如下

Call to a member function free_result() on a non-object