douyun1852
2014-10-13 14:17
浏览 62
已采纳

mysqli_fetch_object不返回对象

Here is my query:

$row = mysqli_fetch_object(mysqli_query("SELECT * FROM `page` AS p LEFT JOIN `page_settings` AS s ON p.id = s.page_id WHERE p.id = '".$this->id."'"));
echo $row->title;

This query returns error like this:

Notice: Trying to get property of non-object in...

But when I try this query:

$row = mysqli_fetch_object(mysqli_query("SELECT * FROM `page` WHERE id = '".$this->id."'"));
echo $row->title;

It works perfectly. I understood nothing.

图片转代码服务由CSDN问答提供 功能建议

这是我的查询:

  $ row = mysqli_fetch_object(  mysqli_query(“SELECT * FROM`page` AS p LEFT JOIN`page_settings` AS s on p.id = s.page_id WHERE p.id ='”。$ this-> id。“'”)); 
echo $  row-> title; 
   
 
 

此查询返回如下错误:

 注意:尝试获取属性 非对象的... 
   
 
 

但是当我尝试这个查询时:

  $ row = mysqli_fetch_object  (mysqli_query(“SELECT * FROM`page` WHERE id ='”。$ this-> id。“'”)); 
echo $ row-> title; 
   
  
 

完美无缺。 我什么都不懂。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dow66098 2014-10-14 07:56
    已采纳

    The reason you get the Trying to get property of non-object error is because your query did not go through and therefore it's not an object, but an error message (or null at some cases).

    So the answer is, because your query failed.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题