• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange error in custom library

#1
[eluser]Razican[/eluser]
Hello, I have modified the OnlineUsers library, and changed the file variable to one in the app/data/ directory. I have that section like this:

Code:
class Online_users{
    var $file    = APPATH.'data/online_users.tmp';
    var $data;

It says that there is an error in
Code:
APPATH.'data/online_users.tmp';

Code:
Parse error: syntax error, unexpected '.', expecting ',' or ';' in application/libraries/Online_users.php on line 15

How can I solve that?

#2
[eluser]WanWizard[/eluser]
It's complaining about the concatenation dot, you can't put an expression in a class property declaration.

#3
[eluser]Razican[/eluser]
I have changed that into this:
Code:
var $file            = 'data/online_users.tmp';
    var $data;
    var $ip;

    function Online_users()
    {
        $this->file        = APPATH.$this->file;

But it tells me this:
Code:
Use of undefined constant APPATH - assumed 'APPATH'

How can I use that constant into my library?

#4
[eluser]Jeroen Brussich[/eluser]
don't you mean APPPATH ?

#5
[eluser]Razican[/eluser]
Yes, that was the problem, but I get another error.

Is it possible to know the online users with the session class? doing this?

Code:
function online()
    {
        $query                = $this->db->get('sessions');

        return $query->num_rows();
    }

I mean, does the session class delete sessions from the database after $config['sess_time_to_update'] has gone? or it deletes them after $config['sess_expiration']?

It would be easier for me that way. I only want to know how many people has the last activity later than time()-$config['sess_time_to_update'].


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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