Cannot modify header information - Help please !

Discussion in 'PHP' started by xkaser101, Nov 1, 2011.

  1. #1
    Hello,
    First of all i need to express some of my rage to the public by saying THIS IS SO ANNOYING in caps :)
    Anyway I have just finished my website that I spent developing on my machine and now,I decided to publish it on a shared host account,
    So I uploaded my website and i am getting this annoying error everywhere
    Warning: Cannot modify header information - headers already sent by (output started at /home/thtsorg1/public_html/v2/includes/mysql_connect.php:1) in /home/thtsorg1/public_html/v2/login_script.php on line 21
    Code (markup):
    Of course the header i am trying to use here is header('Location : index.php'); and the issue is that i am using a require_once on the mysql_connect.php which contains the database information.
    :(

    Is there a way to retrieve my database information or use the require_once function and still use that header ? if not then any ideas ?

    Many many thanks in advance,
    Kind Regards,
    Issa S.
     
    xkaser101, Nov 1, 2011 IP
  2. dazst

    dazst Active Member

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #2

    The problem is on Line #1 of file mysql_connect.php - most probably an empty space. Remove all empty whitespace and save. Make sure the first character on mysql_connect.php is the <? - Should work.
     
    dazst, Nov 1, 2011 IP
  3. xkaser101

    xkaser101 Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the quick reply, How ever that didn't seem to help as I already have removed every white space ( I think ) exists in the mysql_connect.php file,

    Here is the code in that file


    <?php
    define('DB_HOST','localhost');
    define('DB_USER','thtsorg1');
    define('DB_PASS','password');
    $db_con_rewards = mysqli_connect(DB_HOST, DB_USER, DB_PASS) OR DIE('Could not connect to database :' . mysqli_error());
    $db_con_users = mysqli_connect(DB_HOST, DB_USER, DB_PASS) OR DIE('Could not connect to database :' . mysqli_error());
    $db_con_games = mysqli_connect(DB_HOST,DB_USER, DB_PASS) OR DIE('Could not connect to database :' . mysqli_error());
    $db_con_misc = mysqli_connect(DB_HOST,DB_USER, DB_PASS) OR DIE('Could not connect to database :' . mysqli_error());
    $db_con_forum = mysqli_connect(DB_HOST,DB_USER, DB_PASS) OR DIE('Could not connect to database :' . mysqli_error());
    mysqli_select_db($db_con_rewards, 'thtsorg1_rewards');
    mysqli_select_db($db_con_users, 'thtsorg1_users');
    mysqli_select_db($db_con_games, 'thtsorg1_games');
    mysqli_select_db($db_con_misc, 'thtsorg1_misc');
    mysqli_select_db($db_con_forum, 'thtsorg1_forum');
    mysqli_set_charset($db_con_forum, 'utf8');
    ?>
     
    xkaser101, Nov 1, 2011 IP