【问题标题】:Notice: Object of class stdClass could not be converted to int注意:stdClass 类的对象无法转换为 int
【发布时间】:2013-08-21 22:59:33
【问题描述】:

问题是“stdClass 类的对象无法转换为 int”

这是代码:

$user = mysql_fetch_object(mysql_query("SELECT * FROM `user` WHERE username='$user_name'"));
if($user) == 0){

我该如何解决这个问题?

【问题讨论】:

    标签: class object int stdclass


    【解决方案1】:

    您正在从数据库中获取对象,而不是字符串或 int 所以需要在你的类中访问metchod,然后例如检查可以通过以下方式完成一个字段:

    if ($user->user_id === null )
    
    or
    
    if ($user->{'user.id'} == null )
    
    if there are problems with `user.id`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多