Call to a member function on a non-object - works localhost but not online

痴心易碎 提交于 2019-11-28 13:33:17

问题


i got problem with a login script, the thing is i've already instantiated the object, but still got the message saying "Call to a member function on a non-object". Also, note that this code works on localhost, but when i try to run it online i get this message.

have two php files:login.php and connect.php

here is simplified code from connect.php

class Connect{
   var $logged;

   function check_login($uname, $pass){
      $db=new DB;
      $hashed_password=$db->get_password();
      if( $pass == $hashed_password){
         $this->logged=true;               // works - i checked with die() function
         ..
      }
   }
   function simple(){
      return 'yes';
   }
}
$user=new Connect;

here is simplified code from login.php

include_once('connect.php');
$user->check_login($uname, $pass);          // works
var_dump($user->logged);                    // i get NULL - why!?
$data=$user->simple();                      // doesn't work!

Does anyone know why i get empty attributes and this message when i try to call simple() method?

来源:https://stackoverflow.com/questions/7625941/call-to-a-member-function-on-a-non-object-works-localhost-but-not-online

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!