• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with obejct in php4

#1
[eluser]Unknown[/eluser]
Hi,
I have problem:
Quote:Fatal error: Call to a member function on a non-object in (..) system/application/libraries/Access.php on line 34

Line 34: $this->ip1 = $this->obj->session->userdata('ip_address');
Line 35: $this->ip2 = $this->obj->input->ip_address();

File access.php
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
class Access
{
var $obj;
var $ip1;
var $ip2;
function __construct()
{
  $this->obj =& get_instance();
}
function login($user, $password)
{
  $query = $this->obj->db->query("SELECT userId, userNick FROM twp_users WHERE userNick ='$user' AND userPassword = '$password'");
  if($query->num_rows() == 1)
  {
   if ($query->result())
   {
$query = $query->row();
$user = array('userLogin' => $query->userNick,
  'userId' => $query->userId,
  'isLogged' => true);
$this->obj->session->set_userdata($user);
return true;
   }
  }
  else
  {
   return false;
  }
}
function check()
{
  $this->ip1 = $this->obj->session->userdata('ip_address');
  $this->ip2 = $this->obj->input->ip_address();
  if($this->ip1 == $this->ip2 && $this->obj->session->userdata('isLogged') == true)
  {
   return true;
  }
  else
  {
   return false;
  }
}
function logout()
{
  $user = array('userLogin' => null,
    'userId' =>null,
    'isLogged' => null);
   $this->obj->session->set_userdata($user);
   redirect('login');
}
}
?>
I think it doesn't work because i try to use on php4(on php5 work well)
I have php5 in server, but only in .php5 extension(Can`t use .htaccess with "AddType php5-cgi .php")
When i rename access.php to access.php5 doesn't work. Can I rename all files to *.php5?

Sry for my English Wink

EDIT
grr.. "function __construct()" ;D

#2
[eluser]James Spibey[/eluser]
I think it's because you are getting your pointer to the CI instance (get_instance()) in your constructor which doesn't work on php4 (see http://ellislab.com/codeigniter/user-gui...aries.html for details)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.