MySql header errors - help!

Discussion in 'PHP' started by twizzlers, Nov 11, 2009.

  1. #1
    My site suddenly started getting these errors (I don't recall having touched anything to set it off)

    Line 210 in database.php is the bolded part:

    Line 37 in session.php is

    I've tried re-uploading the files and backup files, so I don't think it's a path or typo error...

    Can anyone help? Much appreciated.
     
    twizzlers, Nov 11, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    function calcNumActiveGuests(){
        /* Calculate number of guests at site */
        $q = "SELECT * FROM `".TBL_ACTIVE_GUESTS."`";
        $result = mysql_query($q, $this->connection);
        if(!$result) die($q.'<br />'.mysql_error());
        $this->num_active_guests = mysql_numrows($result);
    } 
    PHP:
    Try that
     
    JAY6390, Nov 11, 2009 IP
  3. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Then I get this on my site and nothing else:

    :(
     
    twizzlers, Nov 11, 2009 IP
  4. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    simple...
    these are warnings not errors..
    just disable them from php.ini config file...
     
    xenon2010, Nov 11, 2009 IP
  5. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ^How?

    And I also can't log out of the admin panel account..so it seems like an error?
     
    twizzlers, Nov 11, 2009 IP
  6. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    for session warnings you need to put the session_start() in the top of your script..
    for header warnings you must make sure nothing output before the header function.. no echos no any html content...
     
    xenon2010, Nov 12, 2009 IP
  7. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This is the whole first half of my session, up to the session_start()

    Not sure what I do to fix it..please advise!
     
    twizzlers, Nov 12, 2009 IP
  8. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This is the problem
    TBL_ACTIVE_GUESTS
    If you read the output from the code you will see that the table has crashed and needs repairing. This is why you are getting errors from mysql, causing the onslaught of other minor warnings
     
    JAY6390, Nov 12, 2009 IP
  9. ProxyKing

    ProxyKing Peon

    Messages:
    268
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Add ob_start(); at the top to fix the header cache problem.
     
    ProxyKing, Nov 12, 2009 IP
  10. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    <?
    class Session
    {
    var $username; //Username given on sign-up
    var $userid; //Random value generated on current login
    var $userlevel; //The level to which the user pertains
    var $time; //Time user was last active (page loaded)
    var $logged_in; //True if user is logged in, false otherwise
    var $userinfo = array(); //The array holding all user info
    var $url; //The page url current being viewed
    var $referrer; //Last recorded site page viewed
    /**
    * Note: referrer should really only be considered the actual
    * page referrer in process.php, any other time it may be
    * inaccurate.
    */
    
    /**
    * startSession - Performs all the actions necessary to
    * initialize this session object. Tries to determine if the
    * the user has logged in already, and sets the variables
    * accordingly. Also takes advantage of this page load to
    * update the active visitors tables.
    */
    function startSession(){
    session_start(); //Tell PHP to start the session
    global $database; //The database connection
    }
    
    /* Class constructor */
    function Session(){
    $this->startSession();
    $this->time = time();
    
    }
    }
    
    
    include_once("database.php");
    include("mailer.php");
    include("form.php");
    
     
    PHP:
    Try to put your code inthis order...
     
    xenon2010, Nov 12, 2009 IP
  11. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Without correcting the database error this is never going to work... :rolleyes:
     
    JAY6390, Nov 12, 2009 IP
  12. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    How do I correct the database error?
     
    twizzlers, Nov 12, 2009 IP
  13. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #13
    You need to run the SQL statement
    REPAIR TABLE `active_guests`
    If you can make a backup beforehand this is good as it will save possible loss of data should the repair go wrong

    Disclaimer: I take no responsibility for this going wrong. For info on repairing tables see http://dev.mysql.com/doc/refman/5.0/en/repair-table.html
     
    JAY6390, Nov 12, 2009 IP
  14. twizzlers

    twizzlers Peon

    Messages:
    291
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    It worked! Site loads quite slowly now, but at least it works

    Thanks so much!!! :)
     
    twizzlers, Nov 12, 2009 IP
  15. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #15
    No problem :cool:
     
    JAY6390, Nov 12, 2009 IP