1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Error - Illegal string offset

Discussion in 'PHP' started by DarkMatrix, Feb 12, 2014.

  1. #1
    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
    :)
     
    Solved! View solution.
    DarkMatrix, Feb 12, 2014 IP
  2. livedating

    livedating Active Member

    Messages:
    161
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    83
    #2
    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:
     
    Last edited: Feb 12, 2014
    livedating, Feb 12, 2014 IP
  3. DarkMatrix

    DarkMatrix Active Member

    Messages:
    310
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    55
    #3
    not working > Fatal error: Call to undefined function getUser() in /home/***/public_html/***/includes/update_users_online.php on line 5
     
    DarkMatrix, Feb 12, 2014 IP
  4. livedating

    livedating Active Member

    Messages:
    161
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    83
    #4
    Then also try to add this on top of the script:
    require_once 'config.php';
    include 'includes/core.php';
    Code (markup):
     
    livedating, Feb 12, 2014 IP
  5. DarkMatrix

    DarkMatrix Active Member

    Messages:
    310
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    55
    #5
    :rolleyes: leave it script working fine i think this is not a major error
     
    DarkMatrix, Feb 12, 2014 IP
  6. #6
    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.
     
    livedating, Feb 12, 2014 IP
  7. DarkMatrix

    DarkMatrix Active Member

    Messages:
    310
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    55
    #7
    Thanx Works for me :)
     
    DarkMatrix, Feb 12, 2014 IP
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    That's not really a fix, it just suppresses the symptoms. Definitely not the right way to do things.
     
    PoPSiCLe, Feb 12, 2014 IP
  9. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #9
    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.
     
    Rukbat, Feb 12, 2014 IP
  10. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #10
    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.
     
    bartolay13, Feb 12, 2014 IP