rofl90 Posted March 30, 2008 Share Posted March 30, 2008 Heres my code, supposed to adapt some shortcode, and turn it into something like Welcome, *user*, you have *x* messages. <?php $get_welcome_temp = $db->query("SELECT welcome FROM settings"); $welcome_array = $db->fetch_array($get_welcome_temp); $date = date($settings->date_format(), time()); $userid = $user->getuserid(); $unread_sql = $db->query("SELECT * FROM messages WHERE unread='1' AND tox='$userid'"); $unread_messages = $db->num_rows($unread_sql); $session_id = session_id(); $la_sql = $db->query("SELECT date FROM session WHERE session_id='$session_id'"); $la_array = $db->fetch_array($la_sql); $last_active_a = $la_array['date']; $last_active = date($settings->date_format(), $last_active_a); $says_template = str_replace("{username}", $logged_user, $welcome_array); $says_template = str_replace("{unread_messages}", $unread_messages, $welcome_array); $says_template = str_replace("{date_now}", $date, $welcome_array); $says_template = str_replace("{last_active}", $last_active, $welcome_array); echo $says_template; ?> Link to comment https://forums.phpfreaks.com/topic/98662-just-says-array/ Share on other sites More sharing options...
$username Posted March 30, 2008 Share Posted March 30, 2008 Are you getting any errors on this? Anything being echoed? Link to comment https://forums.phpfreaks.com/topic/98662-just-says-array/#findComment-504925 Share on other sites More sharing options...
rofl90 Posted March 30, 2008 Author Share Posted March 30, 2008 Nope just "array" heres the functions used: (maybe be extras): user.php: <?php /** * User Core */ class user extends database { /** * __Construct() */ function __construct() { parent::__construct (); } /** * Check user type */ public function user_type($page) { global $logged_user; $user = $logged_user; $level = $this->query("SELECT * FROM users WHERE user='$user'"); $level_a = $this->fetch_array($level); $final_level = $level_a['usergroup']; $check_level = $this->query("SELECT * FROM userstructure WHERE name='$final_level'"); $check_level_a = $this->fetch_array($check_level); if ( $check_level_a[$page] == '1' ) { return "1"; } else { return "0"; } } /** * Get username */ public function getuid() { $session = session_id(); $get_user_id = $this->query("SELECT * FROM session WHERE session_id='$session'"); $fetch_user_id = $this->fetch_array($get_user_id); $user_id_tag = $fetch_user_id['userid']; $get_user_name = $this->query("SELECT * FROM users WHERE id='$user_id_tag'"); $fetch_user_name = $this->fetch_array($get_user_name); $logged_user = $fetch_user_name["user"]; return $logged_user; } /** * Get userid */ public function getuserid() { $session = session_id(); $get_user_id = $this->query("SELECT * FROM session WHERE session_id='$session'"); $fetch_user_id = $this->fetch_array($get_user_id); $user_id_tag = $fetch_user_id['userid']; return $user_id_tag; } /** * Login function */ public function check_login() { global $settings; $id = session_id (); $start = $this->query("SELECT * FROM session WHERE session_id='$id'" ); $start_n = $this->num_rows( $start ); if ($start_n == "0") { return "0"; } else { $get_session_a = $this->fetch_array( $start ); $user_id = $get_session_a ["userid"]; $check_user = $this->query("SELECT * FROM users WHERE id='$user_id'" ); $c_u_n = $this->num_rows( $check_user ); if ($c_u_n == "0") { return "0"; } else { $timeout = $settings->timeout(); $now = time (); $last = $get_session_a ["date"]; $check = $now - $last; if ($check > $timeout) { return "0"; } else { $this->query("UPDATE session SET date='$now' WHERE session_id='$id'" ); return "1"; } } } } /** * __Destruct() */ public function __destruct() { } } /** * Create $user if not existing already */ if (! isset ( $user )) { $user = new user(); } /** * Creating an easier to handle username var. */ $logged_user = $user->getuid(); ?> settings.php: <?php /** * Settings Core */ class settings extends database { /** * __Construct() */ public function __construct() { parent::__construct (); } public function site_title() { $get_site_title = $this->query("SELECT sitetitle FROM settings"); $site_title_array = $this->fetch_array($get_site_title); return $site_title_array['sitetitle']; } public function footer() { $get_footer = $this->query("SELECT footer FROM settings"); $footer_array = $this->fetch_array($get_footer); return $footer_array['footer']; } public function keywords() { $get_keywords = $this->query("SELECT keywords FROM settings"); $keywords_array = $this->fetch_array($get_keywords); return $keywords_array['keywords']; } public function description() { $get_description = $this->query("SELECT description FROM settings"); $description_array = $this->fetch_array($get_description); return $description_array['description']; } public function timeout() { $get_timeout = $this->query("SELECT timeout FROM settings"); $timeout_array = $this->fetch_array($get_timeout); return $timeout_array['timeout']; } public function maintenance() { $get_maintenance = $this->query("SELECT maintenance FROM settings"); $maintenance_array = $this->fetch_array($maintenance_description); return $maintenance_array['maintenance']; } public function welcome() { $get_welcome = $this->query("SELECT welcome FROM settings"); $welcome_array = $this->fetch_array($get_welcome); return $welcome_array['welcome']; } public function date_format() { $get_date_format = $this->query("SELECT date_format FROM settings"); $date_format_array = $this->fetch_array($get_date_format); return $date_format_array['date_format']; } /** * __Destruct() */ public public function __destruct() { } } /** * Create $user if not existing already */ if (! isset ( $settings )) { $settings = new settings(); } ?> Link to comment https://forums.phpfreaks.com/topic/98662-just-says-array/#findComment-504931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.