Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

$result = mysql_result Helpp

Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
Okay so I have an online habbo retro and I am trying to display how many users are online at the time, So in my database I have a users table which holds the user profile data, with an 'online' column, it turn to '0' when offline and turn to '1' when the user is online. So I created a code that gets the info but it only to stay zero , because it just getting the default value. So here the code I made up, I need it to calculate the TOTAL users at that moment.... I am new to php and getting info from a database, its almost common sense in a way if you look at the codes I am seeming to understand I am just a little stuck....
Here is what I got ,
PHP:
<?php
$result = mysql_result(mysql_query('SELECT `online` FROM `users` LIMIT 1'), 0);
echo $result;
?>
 

Ben

Developer - JS
Developer
Joined
Jul 6, 2013
Messages
1,224
Reaction score
506
Okay so I have an online habbo retro and I am trying to display how many users are online at the time, So in my database I have a users table which holds the user profile data, with an 'online' column, it turn to '0' when offline and turn to '1' when the user is online. So I created a code that gets the info but it only to stay zero , because it just getting the default value. So here the code I made up, I need it to calculate the TOTAL users at that moment.... I am new to php and getting info from a database, its almost common sense in a way if you look at the codes I am seeming to understand I am just a little stuck....
Here is what I got ,
PHP:
<?php
$result = mysql_result(mysql_query('SELECT `online` FROM `users` LIMIT 1'), 0);
echo $result;
?>

I'dd say change you SQL query to select the rows with only a 1 in it, and then count that up?

Like

Code:
SELECT COUNT(*)
FROM yourtable
WHERE online='1'
 
Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
I'dd say change you SQL query to select the rows with only a 1 in it, and then count that up?

Like

Code:
SELECT COUNT(*)
FROM yourtable
WHERE online='1'

So this ?
PHP:
<?php
$result = mysql_result(mysql_query(SELECT COUNT(*)
FROM users
WHERE online='1');
echo $result;
?>



I seemed to do just that and It got an error
 

Ben

Developer - JS
Developer
Joined
Jul 6, 2013
Messages
1,224
Reaction score
506
So this ?
PHP:
<?php
$result = mysql_result(mysql_query(SELECT COUNT(*)
FROM users
WHERE online='1');
echo $result;
?>



I seemed to do just that and It got an error

Just did a quick test, created a small db with 2 fields.

Query:
Code:
SELECT COUNT(online) AS onlineUsers FROM users
WHERE online=1;

Seems to work fine as it returns me the correct value according to my test.
 
Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
Just did a quick test, created a small db with 2 fields.

Query:
Code:
SELECT COUNT(online) AS onlineUsers FROM users
WHERE online=1;

Seems to work fine as it returns me the correct value according to my test.

So does this look right ? I am doing something wrong,
PHP:
 <?php
$result = mysql_result(mysql_query(SELECT COUNT(online) AS onlineUsers FROM users
WHERE online=1;);
echo $result;
?>
 

Ben

Developer - JS
Developer
Joined
Jul 6, 2013
Messages
1,224
Reaction score
506
So does this look right ? I am doing something wrong,
PHP:
 <?php
$result = mysql_result(mysql_query(SELECT COUNT(online) AS onlineUsers FROM users
WHERE online=1;);
echo $result;
?>

You don't need to put the ; within the ) i'm pretty sure that'll give you a syntax error.

Code:
$result = mysql_result(mysql_query(SELECT COUNT(online) AS onlineUsers FROM users
WHERE online=1);

I used it straight on the db, with a mysql query, so the query is correct, that for sure.

here's a SS of the test db i used
RWu9yF1 - $result = mysql_result Helpp - RaGEZONE Forums

j3dUBr - $result = mysql_result Helpp - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
Yeah but my db doesnt have onlineusers as a column
 

Ben

Developer - JS
Developer
Joined
Jul 6, 2013
Messages
1,224
Reaction score
506
Yeah but my db doesnt have onlineusers as a column

Onlineusers is an alias for the value that it returns from the count(online), online is the column that stores the 1/0's the onlineusers doesn't affect it at any kind, you can keep it out of the statement.

replace the online with the table that contains your 1 or 0 and it should work too.
 
Skilled Illusionist
Joined
Mar 26, 2013
Messages
371
Reaction score
280
SELECT users_online FROM server_status;

This will work if you use PlusEMU.

And 'online' field isn't a INTEGER, is a ENUM. You can't compare it to 1.

SELECT COUNT(online) as count FROM users WHERE online = 1; will return 1000 if you have 1000 users on your database.

SELECT COUNT(online) as count FROM users WHERE online = '1'; this will work correctly. Anyway, use first query.
 
Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
SELECT users_online FROM server_status;

This will work if you use PlusEMU.

And 'online' field isn't a INTEGER, is a ENUM. You can't compare it to 1.

SELECT COUNT(online) as count FROM users WHERE online = 1; will return 1000 if you have 1000 users on your database.

SELECT COUNT(online) as count FROM users WHERE online = '1'; this will work correctly. Anyway, use first query.

But server status doesnt work, its all null at all times i check the colums...

How does this look ?
PHP:
<?php
$result = mysql_result(mysql_query(SELECT COUNT(online) as count FROM users WHERE online = 1);
echo $result;
?>



Still not working
http://142.4.196.46/test
 
Skilled Illusionist
Joined
Mar 26, 2013
Messages
371
Reaction score
280
But server status doesnt work, its all null at all times i check the colums...

How does this look ?
PHP:
<?php
$result = mysql_result(mysql_query(SELECT COUNT(online) as count FROM users WHERE online = 1);
echo $result;
?>



Still not working

The PHP code is wrong.

PHP:
<?php
$result = mysql_result(mysql_query("SELECT COUNT(online) as count FROM users WHERE online = '1';"), 0);
echo $result;
 
Divine Celestial
Loyal Member
Joined
Oct 2, 2011
Messages
858
Reaction score
272
The PHP code is wrong.

PHP:
<?php
$result = mysql_result(mysql_query("SELECT COUNT(online) as count FROM users WHERE online = '1';"), 0);
echo $result;

Works excellent, thanks everyone for helping me appreciate it !



So I have that fixed so I can now get the online user amount to displace and appear on a .php file on my site, so using this edit of a cms, has a list of variables created in a .php files that is then used across the whole site...
Here;

PHP:
global $_CONFIG, $users, $engine, $core, $template;
		$this->setParams('hotelName', $_CONFIG['hotel']['name']);
		$this->setParams('hotelDesc', $_CONFIG['hotel']['desc']);
		$this->setParams('url', $_CONFIG['hotel']['url']);
		[B]$this->setParams('online', $users->getInfo($SESSION['users']['online']));[/B]
		$this->setParams('status', $core->getStatus());
		$this->setParams('web_build', $_CONFIG['hotel']['web_build']);
		$this->setParams('external_vars', $_CONFIG['hotel']['external_vars']);
		$this->setParams('external_texts', $_CONFIG['hotel']['external_texts']);
		$this->setParams('swf_folder', $_CONFIG['hotel']['swf_folder']);
		$this->setParams('furni_data', $_CONFIG['hotel']['furni_data']);
		$this->SetParams('product_data', $_CONFIG['hotel']['product_data']);
		$this->setParams('server_ip', $_CONFIG['hotel']['server_ip']);
		
		$this->setParams('mysql_host', $_CONFIG['mysql']['hostname']);
		$this->setParams('mysql_port', $_CONFIG['mysql']['port']);
		
		$this->setParams('skin', $_CONFIG['template']['style']);
Since that code is broken due to my db structure, and now I am trying to use this;
PHP:
<?php
$result = mysql_result(mysql_query("SELECT COUNT(online) as count FROM users WHERE online = '1';"), 0);
echo $result;

I tried to fomat it to a
PHP:
$this->setParams

But I keep failing .... Is there a way to make it a sql, or make it display the php file that displays the online users using the sql above ? like echo $result FROM online.php

Ive tried....


BurakDev
 
Joined
May 15, 2009
Messages
799
Reaction score
558
you really should stop using mysql_query and likes of mysql_ there all deprecated in newer php version

if you like i can give you a pdo class that will work better for you.

pdo.class.php
Code:
<?php
   /**
   * 
   * 
   * Author : Advocaite
   * 
   * 
   */
class DB
{
    # [USER=2000056467]Object[/USER], The PDO object
    private $pdo;

    # [USER=2000056467]Object[/USER], PDO statement object
    private $sQuery;

    # [USER=1333341984]Array[/USER],  The database settings
    private $settings;

    # [USER=2000177372]BOOL[/USER] ,  Connected to the database
    private $bConnected = false;

    # [USER=2000056467]Object[/USER], Object for logging exceptions    
    private $log;

    # [USER=1333341984]Array[/USER], The parameters of the SQL query
    private $parameters;
        
       /**
    *   Default Constructor 
    *
    *    1. Instantiate Log class.
    *    2. Connect to database.
    *    3. Creates the parameter array.
    */
        public function __construct()
        {             
            $this->Connect();
            $this->parameters = array();
        }
    
       /**
    *    This method makes connection to the database.
    *    
    *    1. Reads the database settings from a ini file. 
    *    2. Puts  the ini content into the settings array.
    *    3. Tries to connect to the database.
    *    4. If connection failed, exception is displayed and a log file gets created.
    */
        private function Connect()
        {
            $this->settings = parse_ini_file("settings.ini.php");
            $dsn = 'mysql:dbname='.$this->settings["dbname"].';host='.$this->settings["host"].'';
            try 
            {
                # Read settings from INI file
                $this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"]);
                
                # We can now log any exceptions on Fatal error. 
                $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                
                # Disable emulation of prepared statements, use REAL prepared statements instead.
                $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                
                # Connection succeeded, set the boolean to true.
                $this->bConnected = true;
            }
            catch (PDOException $e) 
            {
                # Write into log
                echo $this->ExceptionLog($e->getMessage());
                die();
            }
        }
       /**
    *    Every method which needs to execute a SQL query uses this method.
    *    
    *    1. If not connected, connect to the database.
    *    2. Prepare Query.
    *    3. Parameterize Query.
    *    4. Execute Query.    
    *    5. On exception : Write Exception into the log + SQL query.
    *    6. Reset the Parameters.
    */    
        private function Init($query,$parameters = "")
        {
        # Connect to database
        if(!$this->bConnected) { $this->Connect(); }
        try {
                # Prepare query
                $this->sQuery = $this->pdo->prepare($query);
                
                # Add parameters to the parameter array    
                $this->bindMore($parameters);

                # Bind parameters
                if(!empty($this->parameters)) {
                    foreach($this->parameters as $param)
                    {
                        $parameters = explode("\x7F",$param);
                        $this->sQuery->bindParam($parameters[0],$parameters[1]);
                    }        
                }

                # Execute SQL 
                $this->succes     = $this->sQuery->execute();        
            }
            catch(PDOException $e)
            {
                    # Write into log and display Exception
                    echo $this->ExceptionLog($e->getMessage(),$this->sQuery->queryString);
                    die();
            }

            # Reset the parameters
            $this->parameters = array();
        }
        
       /**
    *    [USER=237674]Void[/USER] 
    *
    *    Add the parameter to the parameter array
    *    [USER=2000183830]para[/USER]m string $para  
    *    [USER=2000183830]para[/USER]m string $value 
    */    
        public function bind($para, $value)
        {    
            $this->parameters[sizeof($this->parameters)] = ":" . $para . "\x7F" . $value;
        }
       /**
    *    [USER=237674]Void[/USER]
    *    
    *    Add more parameters to the parameter array
    *    [USER=2000183830]para[/USER]m array $parray
    */    
        public function bindMore($parray)
        {
            if(empty($this->parameters) && is_array($parray)) {
                $columns = array_keys($parray);
                foreach($columns as $i => &$column)    {
                    $this->bind($column, $parray[$column]);
                }
            }
        }
    /**
    *   If the SQL query  contains a SELECT statement it returns an array containing all of the result set row
    *    If the SQL statement is a DELETE, INSERT, or UPDATE statement it returns the number of affected rows
    *
    *       [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=2000183830]para[/USER]m  int    $fetchmode
    *    [USER=850422]return[/USER] mixed
    */            
        public function query($query,$params = null,$fetchmode = PDO::FETCH_ASSOC)
        {
            $query = trim($query);

            $this->Init($query,$params);

            if (stripos($query, 'select') === 0){
                return $this->sQuery->fetchAll($fetchmode);
            }
            elseif (stripos($query, 'insert') === 0 ||  stripos($query, 'update') === 0 || stripos($query, 'delete') === 0) {
                return $this->sQuery->rowCount();    
            }    
            else {
                return NULL;
            }
        }        
       /**
    *    Returns an array which represents a column from the result set 
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=850422]return[/USER] array
    */    
        public function column($query,$params = null)
        {
            $this->Init($query,$params);
            $Columns = $this->sQuery->fetchAll(PDO::FETCH_NUM);        
            
            $column = null;

            foreach($Columns as $cells) {
                $column[] = $cells[0];
            }

            return $column;
            
        }    
       /**
    *    Returns an array which represents a row from the result set 
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *       [USER=2000183830]para[/USER]m  int    $fetchmode
    *    [USER=850422]return[/USER] array
    */    
        public function row($query,$params = null,$fetchmode = PDO::FETCH_ASSOC)
        {                
            $this->Init($query,$params);
            return $this->sQuery->fetch($fetchmode);            
        }
       /**
    *    Returns the value of one single field/column
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=850422]return[/USER] string
    */    
        public function single($query,$params = null)
        {
            $this->Init($query,$params);
            return $this->sQuery->fetchColumn();
        }
        /**
        * grab the last insterted query id
        * 
        */
        public function get_last_id(){
         return $this->pdo->lastInsertId();
        }
       /**    
    * Writes the log and returns the exception
    *
    * [USER=2000183830]para[/USER]m  string $message
    * [USER=2000183830]para[/USER]m  string $sql
    * [USER=850422]return[/USER] string
    */
    private function ExceptionLog($message , $sql = "")
    {
        $exception  = 'Unhandled Exception. <br />';
        $exception .= $message;
        $exception .= "<br /> DEATH FOR YOU.";

        if(!empty($sql)) {
            # Add the Raw SQL to the Log
            $exception .= "\r\nRaw SQL : "  . $sql;
        }

        return $exception;
    }            
}
?>
settings.ini.php
Code:
[SQL]
host = localhost
user = user
password = password
dbname = dbname

example of use
Code:
require_once( 'DB.php');
//Setup the DB
$db = new Db();

$params = array('parramvaule' => $somevar, 'paramvalue2' => $somevar2);
 $db->query('UPDATE tablename SET tablecolum = :parramvaule WHERE tablecolum = :paramvalue2' ,$params);

welcome to prepared statements :)
 
Newbie Spellweaver
Joined
Sep 8, 2015
Messages
26
Reaction score
4
you really should stop using mysql_query and likes of mysql_ there all deprecated in newer php version

if you like i can give you a pdo class that will work better for you.

pdo.class.php
Code:
<?php
   /**
   * 
   * 
   * Author : Advocaite
   * 
   * 
   */
class DB
{
    # [USER=2000056467]Object[/USER], The PDO object
    private $pdo;

    # [USER=2000056467]Object[/USER], PDO statement object
    private $sQuery;

    # [USER=1333341984]Array[/USER],  The database settings
    private $settings;

    # [USER=2000177372]BOOL[/USER] ,  Connected to the database
    private $bConnected = false;

    # [USER=2000056467]Object[/USER], Object for logging exceptions    
    private $log;

    # [USER=1333341984]Array[/USER], The parameters of the SQL query
    private $parameters;
        
       /**
    *   Default Constructor 
    *
    *    1. Instantiate Log class.
    *    2. Connect to database.
    *    3. Creates the parameter array.
    */
        public function __construct()
        {             
            $this->Connect();
            $this->parameters = array();
        }
    
       /**
    *    This method makes connection to the database.
    *    
    *    1. Reads the database settings from a ini file. 
    *    2. Puts  the ini content into the settings array.
    *    3. Tries to connect to the database.
    *    4. If connection failed, exception is displayed and a log file gets created.
    */
        private function Connect()
        {
            $this->settings = parse_ini_file("settings.ini.php");
            $dsn = 'mysql:dbname='.$this->settings["dbname"].';host='.$this->settings["host"].'';
            try 
            {
                # Read settings from INI file
                $this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"]);
                
                # We can now log any exceptions on Fatal error. 
                $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                
                # Disable emulation of prepared statements, use REAL prepared statements instead.
                $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                
                # Connection succeeded, set the boolean to true.
                $this->bConnected = true;
            }
            catch (PDOException $e) 
            {
                # Write into log
                echo $this->ExceptionLog($e->getMessage());
                die();
            }
        }
       /**
    *    Every method which needs to execute a SQL query uses this method.
    *    
    *    1. If not connected, connect to the database.
    *    2. Prepare Query.
    *    3. Parameterize Query.
    *    4. Execute Query.    
    *    5. On exception : Write Exception into the log + SQL query.
    *    6. Reset the Parameters.
    */    
        private function Init($query,$parameters = "")
        {
        # Connect to database
        if(!$this->bConnected) { $this->Connect(); }
        try {
                # Prepare query
                $this->sQuery = $this->pdo->prepare($query);
                
                # Add parameters to the parameter array    
                $this->bindMore($parameters);

                # Bind parameters
                if(!empty($this->parameters)) {
                    foreach($this->parameters as $param)
                    {
                        $parameters = explode("\x7F",$param);
                        $this->sQuery->bindParam($parameters[0],$parameters[1]);
                    }        
                }

                # Execute SQL 
                $this->succes     = $this->sQuery->execute();        
            }
            catch(PDOException $e)
            {
                    # Write into log and display Exception
                    echo $this->ExceptionLog($e->getMessage(),$this->sQuery->queryString);
                    die();
            }

            # Reset the parameters
            $this->parameters = array();
        }
        
       /**
    *    [USER=237674]Void[/USER] 
    *
    *    Add the parameter to the parameter array
    *    [USER=2000183830]para[/USER]m string $para  
    *    [USER=2000183830]para[/USER]m string $value 
    */    
        public function bind($para, $value)
        {    
            $this->parameters[sizeof($this->parameters)] = ":" . $para . "\x7F" . $value;
        }
       /**
    *    [USER=237674]Void[/USER]
    *    
    *    Add more parameters to the parameter array
    *    [USER=2000183830]para[/USER]m array $parray
    */    
        public function bindMore($parray)
        {
            if(empty($this->parameters) && is_array($parray)) {
                $columns = array_keys($parray);
                foreach($columns as $i => &$column)    {
                    $this->bind($column, $parray[$column]);
                }
            }
        }
    /**
    *   If the SQL query  contains a SELECT statement it returns an array containing all of the result set row
    *    If the SQL statement is a DELETE, INSERT, or UPDATE statement it returns the number of affected rows
    *
    *       [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=2000183830]para[/USER]m  int    $fetchmode
    *    [USER=850422]return[/USER] mixed
    */            
        public function query($query,$params = null,$fetchmode = PDO::FETCH_ASSOC)
        {
            $query = trim($query);

            $this->Init($query,$params);

            if (stripos($query, 'select') === 0){
                return $this->sQuery->fetchAll($fetchmode);
            }
            elseif (stripos($query, 'insert') === 0 ||  stripos($query, 'update') === 0 || stripos($query, 'delete') === 0) {
                return $this->sQuery->rowCount();    
            }    
            else {
                return NULL;
            }
        }        
       /**
    *    Returns an array which represents a column from the result set 
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=850422]return[/USER] array
    */    
        public function column($query,$params = null)
        {
            $this->Init($query,$params);
            $Columns = $this->sQuery->fetchAll(PDO::FETCH_NUM);        
            
            $column = null;

            foreach($Columns as $cells) {
                $column[] = $cells[0];
            }

            return $column;
            
        }    
       /**
    *    Returns an array which represents a row from the result set 
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *       [USER=2000183830]para[/USER]m  int    $fetchmode
    *    [USER=850422]return[/USER] array
    */    
        public function row($query,$params = null,$fetchmode = PDO::FETCH_ASSOC)
        {                
            $this->Init($query,$params);
            return $this->sQuery->fetch($fetchmode);            
        }
       /**
    *    Returns the value of one single field/column
    *
    *    [USER=2000183830]para[/USER]m  string $query
    *    [USER=2000183830]para[/USER]m  array  $params
    *    [USER=850422]return[/USER] string
    */    
        public function single($query,$params = null)
        {
            $this->Init($query,$params);
            return $this->sQuery->fetchColumn();
        }
        /**
        * grab the last insterted query id
        * 
        */
        public function get_last_id(){
         return $this->pdo->lastInsertId();
        }
       /**    
    * Writes the log and returns the exception
    *
    * [USER=2000183830]para[/USER]m  string $message
    * [USER=2000183830]para[/USER]m  string $sql
    * [USER=850422]return[/USER] string
    */
    private function ExceptionLog($message , $sql = "")
    {
        $exception  = 'Unhandled Exception. <br />';
        $exception .= $message;
        $exception .= "<br /> DEATH FOR YOU.";

        if(!empty($sql)) {
            # Add the Raw SQL to the Log
            $exception .= "\r\nRaw SQL : "  . $sql;
        }

        return $exception;
    }            
}
?>
settings.ini.php
Code:
[SQL]
host = localhost
user = user
password = password
dbname = dbname

example of use
Code:
require_once( 'DB.php');
//Setup the DB
$db = new Db();

$params = array('parramvaule' => $somevar, 'paramvalue2' => $somevar2);
 $db->query('UPDATE tablename SET tablecolum = :parramvaule WHERE tablecolum = :paramvalue2' ,$params);

welcome to prepared statements :)

and instead re inventing the wheel use framework. laravel is a great start or you can use slim skeleton ;)
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
:/: That class and the framework that were just posted are probably too complex for the OP.. I'm under the impression that @Danny just wants to get something working right now, but I suggest learning modern PHP, and for that matter, programming in general.

So, @Danny, what exactly did you try, and why is your site broken due to your database structure? What is $setParam supposed to do, anyway?

Rant: And my two cents- that CMS or framework or w.e you're showing me is using global and deprecated functions, and some of the worst programming I've ever seen. If you do plan on learning PHP, don't learn from that system you're using. Copying data from all over the place and coupling that data into one object is just silly.. It's garbage. I mean, if you want data from $_CONFIG- use $_CONFIG to retrieve that data!! But, there is no sense in having a global $_CONFIG variable in the first place! I also see people do things like `$user = $_POST['user']`- If you're not going to change data from one variable, why would anyone copy it to another variable? I mean, What's wrong with simply referencing $_POST['user']? For one, it's more clear the data is from the client, and poses a danger as all user input does, where the variable $user is smaller and easier to type, but that won't stop anyone from spending hours trying to find the source of a vulnerability in one's code. The tiny bit of time one might spend typing a few extra characters is made up for by the amount of time saved trying to figure out what the hell one did to get into the mess they are in. Similar with the framework you are using, assigning data from several different places into one giant object doesn't save anyone time when it comes time to change data. You first need to ask yourself, where does 'status' come from? You might check $_CONFIG, or perhaps the $user object, before you figure out it comes from $core. All of those are globals, too, so something in the lost Jurassic Park code has the authority to change any of those variables to a tyrannosaurus rex at the worst possible time.

Sorry.. I was just reminded why I was driven away from the PHP programming society. I feel your pain though, at one time I was unlucky enough to have been a beginner programmer learning PHP 4.


Finally, a shot in the dark here, if your problem is this line:

$this->setParams('online', $users->getInfo($SESSION['users']['online']));

Perhaps you forgot an underscore in $_SESSION

Try this:

$this->setParams('online', $users->getInfo($_SESSION['users']['online']));

If that line is your problem, and the said problem wasn't solved by my shot in the dark, I would need to know what $users->getInfo actually does, and what $_SESSION['users']['online'] actually is.
 
Last edited:
Back
Top