Script install successfully but getting this error popup in admin panel >> Warning: Illegal string offset 'login_status' in /home/****/public_html/****/includes/update_users_online.php on line 5 <?php $session=session_id(); $time=time(); if ($user['login_status'] == 1) { $user_id = $user['id']; $sql = mysql_query("SELECT * FROM wss_usersonline WHERE user_id = $user_id"); } (text in red is line 5) Thank you
Assuming this is an AVAcrade script, I believe you should define $user variable before using it as an array. Try to add this above the red line: $user = getUser(); PHP:
not working > Fatal error: Call to undefined function getUser() in /home/***/public_html/***/includes/update_users_online.php on line 5
Then also try to add this on top of the script: require_once 'config.php'; include 'includes/core.php'; Code (markup):
If you just would like to get rid of the error message then you can add @ sign right before $user['login_status'], like this: @$user['login_status'] This would suppress the error message.
The Illegal string offset 'login_status' simply means that if ($user['login_status'] == 1) { is referring to an index into $users[] that doesn't exist. There's no 'login_status' in $users at that point in the code. The fact that you may have declared it in another file, or even globally, doesn't mean that exists in line 5 in that file. You may have gotten some value in $session, but you have to session_start; before there's a session to get values from.
you should not suppress this kind of exceptions, you should supply the variable mentioned, it is simply non existing. suppressing error is not the type of method you want to use in programming. thus, it is not the best answer.