I have a server that has php5. I would rather not have to add php4 to the server. I have a script that i am suspecting was written for php4. It was written in 2005.
I got the following error.
Fatal error: Using $this when not in object context in /var/www/vhosts/savemarriage.aagthosting.com/httpdocs/marriage-workshop/lib/User.class.php on line 227
I checked Google and my $this call is inside of a class. I have pasted the function in the class below and made a comment on the line where the error is. Can someone tell me why I am getting this error.
function listUsers($start=0, $count, $order ='user_lastname', $dir='ASC'){
$sql = new MySQL_class();
$sql->Create();
$users = array();
$qry = ' SELECT u.user_id, u.user_firstname, '
. ' u.user_lastname, u.user_email, u.user_status,'
. ' u.user_created '
. ' FROM tblUsers u '
. ' ORDER BY ' . $order . ' ' . $dir
. ' LIMIT ' . $start . ',' . $count ;
$sql->Query($qry);
if($sql->err_no != 0){
$this->err_no = $sql->err_no; // This is the line with the error
$this->err_msg = $sql->err_msg;
}
for($i=0; $i<$sql->rows; $i++){
$sql->Fetch($i);
$user = new User();
$user->user_id = $sql->data['user_id'];
$user->user_lastname = $sql->data['user_lastname'];
$user->user_firstname = $sql->data['user_firstname'];
$user->user_email = $sql->data['user_email'];
$user->user_created = $sql->data['user_created'];
$user->user_status = $sql->data['user_status'];
$users[$i] = $user;
}
return($users);
}
function totalUsers(){
$sql = new MySQL_class();
$sql->Create();
$qry=' SELECT COUNT(1) as total FROM tblUsers';
$total = $sql->QueryItem($qry);
return ($total);
}