$query = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id=' . $this->uid;
$sql = $db->sql_query ( $query );
$this->user_data = $db->sql_fetch_assoc ( $sql );
$this->lang_name = $this->user_data['user_language'];
$this->timezone = $this->user_data['user_timezone'];
$this->date_format = $this->user_data['user_dateformat'];
$this->user_theme = $this->user_data['user_theme'];
$this->load_user_settings();
The code above is found within a function within the user class. The variable $user_data is a public variable and is expecting an array.
The weirdness i'm finding which is bringing my work to a stand still is the following.
If I echo "$this->lang_name" it will display "en". Which is correct. However, if I echo $this->user_data['user_language'] it will not display anything. This is the same for the other variables.
So the below code will not work either. I've tried print_r and it does not display anything. I've removed my custom database functions and used the norm of mysql_query and mysql_fetch_assoc/mysql_fetch_array and it still does not work.
I've tried echoing $this->user_settings['fieldname'] and no value is being displayed.
I'm using PHP 5.2.9
public function load_user_settings()
{
global $db;
$query = 'SELECT *
FROM ' . USER_SETTINGS_TABLE . '
WHERE user_id=' . $this->uid . '
LIMIT 1';
$sql = $db->sql_query( $query );
$this->user_settings = $db->sql_fetch_assoc( $sql );
}
I've tried;
public $user_data;
public $user_settings;
public $user_data = array();
public $user_settings = array();
to no avail. Please help.