Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1

    Default PHP DATEBASE CONNECTION HELP!

    Hi everybody,

    Need help everytime i go to my index.php web page this appears?





    Warning: Cannot modify header information - headers already sent by (output started at /home/changeme/public_html/Game/includes/db_connect.php:1) in home/changeme/public_html/Game/index.php on line 7




    am pretty sure i have done everythink right can i anybody tell me how this could fixed ? or could anybody try and fix it ?

    Thanks Joe
    Selling Shoutcast!

  2. #2
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    Make sure your opening <?php tag is the VERY FIRST THING on the page.

  3. #3

    Default

    yess they are, any other reasons why its not working ?
    Selling Shoutcast!

  4. #4
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    Move any session_start() or header() calls before ANYTHING is outputted in the file or echo'd.

    And do the same for db_connect.php
    Last edited by Apolva; 24-07-2010 at 07:01 PM.

  5. #5

    Default

    am confusedd i really dont know how to do that ?
    Selling Shoutcast!

  6. #6
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    Paste me the contents of index.php and db_connect.php, minus any sensitive info, I'll take a look.

  7. #7

    Default

    index.php




    <?php
    session_start();
    include_once("includes/db_connect.php");
    if (strip_tags($_GET['logout']) == "yes"){
    session_destroy();
    }elseif (isset($_SESSION['real_name'])){
    header("Location: Updates.php");
    exit();
    }


    if ($_POST['Submit'] && strip_tags($_POST['username']) && strip_tags($_POST['password'])){
    $username = $_POST['username'];
    $password = $_POST['password'];
    $username = strip_tags($username);
    $password = strip_tags($password);
    $ip = $REMOTE_ADDR;


    $date = gmdate('Y-m-d h:i:s');


    ///check INFO
    $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1");
    $login_check = mysql_num_rows($sql);
    $inf = mysql_fetch_object($sql);

    if ($login_check > "0"){
    if ($inf->status == "Dead"){
    include_once"dead.php";
    exit();

    $timenow=time();
    $online = time() - 300; //the current time minus 300 seconds
    $select = mysql_query("SELECT * FROM users WHERE onlinetime2 >='$online' AND online='Online' ORDER by id ASC");
    $num = mysql_num_rows($select);
    $numfor=number_format($num);

    }
    session_register('username');
    $_SESSION['real_name'] = $inf->username;
    $_SESSION["userlevel"] = $inf->userlevel;
    $_SESSION["crewlevel"] = $inf->crewlevel;


    $realip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
    $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

    $time2 = time();

    $timestamp = time()+60;

    mysql_query("UPDATE users SET online='Online', onlinetime2='$time2' WHERE username='$username'");

    mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` , `ip` ) VALUES ('', '$username', 'Logged In!', '$date', '$realip')");

    header("Location: News.php");

    } else {
    $message= "You could not be logged in.<br />";

    }}
    ?>

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <link REL="SHORTCUT ICON" type="image/ico" HREF="icon here">
    <meta name="author" content="Bigharry">
    <title>Mafia-Assassins</title>
    <link href="site_css.css" rel="stylesheet" type="text/css">
    <script src="clienthint.js"></script>
    </head>

    <body bgcolor="black" OnLoad="document.login.mail.focus();">
    <div align="center">

    <strong><font color='red' face='verdana' size='1'> <br>
    <br>
    </font></strong>
    <table width="965" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td valign="bottom">
    <table width="965" border="0" cellspacing="0" cellpadding="0">
    <tr>

    <td width="349" valign="bottom">
    <table width="349" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="23"><div align="center"><img src="banner.jpg" width="966" height="168"></div></td>

    </tr>
    </table>
    </td>


    </tr>
    </table></td>
    </tr>

    <tr>
    <td>
    <table width="965" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="200" valign="top" class="home-side">
    <br>
    <br>
    <div class="brown"><center>Major Updates</center></div>
    <div align="left" class="mafia-game">
    <li>Refferal System has been fixed and updated.<br><br>

    <li>The game layout has been slightly updated.<br><br>
    <li>A blackjack casino is being made.<br><br>
    </div>




    <div align="left" class="mafia-game">
    </div></td>
    <td valign="top">
    <table border="0" cellspacing="0" cellpadding="0" width="565" height="302" class="home-pic1">
    <tr>

    <td height="270" valign="top">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td height="168" valign="top"> <br>
    <p class="home-text"><br>
    <br>
    <a href="Register2.php"><strong></strong></a>
    <font size="-2"></font></p>
    <strong><font color='red' face='verdana' size='1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></strong></td>

    </tr>
    <tr>
    <td valign="bottom">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>

    <form id="form1" name="form1" method="post" action="index.php">



    <div style="padding: 10px 0 0 400px;">

    <input name="username" type="text" class="input-home" id="username" size="15" maxlength="35">

    <br>
    <br>
    <input name="password" type="password" id="password2" class="input-home" size="15" maxlength="35">
    <br>
    <input type="submit" name="Submit" value="Login">
    </div>

    </form> </td>

    </tr>
    </table></td>
    </tr>

    </table>
    <br>
    <br>
    <br>
    <br>
    <br>
    <center>
    <body style="margin: 0px" bgcolor="black" vlink="black" alink="black">

    </body></center>
    </td></tr></table>


    <td width="200" valign="top" class="home-side">


    <div class="mafia-game">
    <br>

    <div class="brown">Need help playing?</div><br>
    We have added a guide to help new users to the game or users that are new to the mafia life.<br>

    <strong><br>
    </strong><br>
    </div></td>
    </tr><div align="center" class="style"><a href="lost_pass.php">Lost Password </a><label> :: </label><a href="Register2.php"> Register </a><label> :: </label><a href="tos.php"> Terms of Service </a>

    <br>
    <br>
    <br>
    <font color="lime"><b>Mafia-Assassins is Open.</b></font></div></center>
    </table>







    </td>
    </tr>
    <tr>
    <td>


    </script></body>
    </html>


    Db Connect.php

    <?php


    $mysql_server = "....";
    $mysql_user = "...";
    $mysql_password = "...";
    $mysql_database = "...";





    $connection = mysql_connect("$mysql_server","$mysql_user","$mysq l_password") or die ("Unable to connect to MySQL server.");
    $db = mysql_select_db("$mysql_database") or die ("Unable to select requested database.");


    ?>

    ---------- Post added 24-07-2010 at 08:13 PM ----------

    thanks this is much appriciated
    Selling Shoutcast!

  8. #8
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    I think you must have empty lines above the opening <?php tag on db_connect.php, remove those and try.

  9. #9

    Default

    nope still no luck
    Selling Shoutcast!

  10. #10
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default

    That error is caused when the headers have already been sent to the browser and you try to add more to the header. You must have flushed them by sending some of the page.

    Are you sure there are no empty lines or spaces before or after the <?php and ?> tags?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •