Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6706795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:33:45+00:00 2026-05-26T07:33:45+00:00

I got an interesting error which says that headers were already sent through ob_end_flush();

  • 0

I got an interesting error which says that headers were already sent through ob_end_flush(); when I run the below code. This is the exact error I am getting

Warning: Cannot modify header information – headers already sent by (output started at /export/home/ua/games/gamescripts/login_backend2.php:47) in /export/home/ua/games/gamescripts/login_backend2.php on line 57 should have redirected by now

line 47 is ob_end_flush();

Edit: Sorry I was a bit careless while pasting my code. I have now arranged it in a right format.

<?php

include_once('Services_JSON.php');
include 'connect.php';
include_once('functions.php');
error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);


$json = new Services_JSON();  
$username=  $_POST["username"];  
$password = $_POST["password"];  

$check=0;  
$query="SELECT * FROM `game_users` WHERE `username` LIKE  '$username'";  
$result = mysql_query($query)  
or  
 die("<br>Query Error: ".mysql_error());  

while($row = mysql_fetch_row($result))  
{  

    $user = $row[2];  
    $pass = $row[3];  
    $name = $row[1];  

        if($username == $user )  
        {  

            if($password == $pass)  
            {    
                              $Day = 86400 + time(); // 1 Day    
                              $name= "name";  
                              $user= "user";  
                              $pass= "password";  
                              ob_start();  
                              //creating cookie for one day  
                              setcookie("username", $user, $Day);  
                              $cookiename = $name.$user;                    
                              setcookie("games", $cookiename, $Day);    
                              createSession($user,$cookiename);  
                              ob_end_flush();  
                              $data = array($user, $pass, $name);           
                              $check=1;  
                              flush();  
                              header("Location:                  http://www.uark.edu/ua/games/gamescripts/Game/Game.html");  
                              die('should have redirected by now');  


            }

        }

}
if($check==0)
{
    $data = array("failed", "failed", "failed","failed");
    echo $json->encode($data);
}
 ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:33:46+00:00Added an answer on May 26, 2026 at 7:33 am

    flush() sends the headers already queued up (the cookies in this case). Remove the flush() call. This code will throw an error about not being able to output the 2nd header:

    <?php
        header('a: 1');
        flush();
        header('b: 2');
    ?>
    

    You can also remove the output buffering – it does nothing useful here. This code works fine, however:

    <?php
        ob_start();
        header('a: 1');
        ob_end_flush();
        header('b: 2');
    ?>
    

    Only flush() actually sends headers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've run across an interesting PHP/SOAP error that has me stymied. After searching I
Attached Firefox to fiddler and got following error. What would cause this error? Interesting
(I asked this question in another way , and got some interesting responses but
Got an interesting scenario I'd like to run past you guys re: DB architecture.
I got an interesting time-travel problem today, using the following code: for (int i
We've got an interesting requirement that we'll want to support multiple languages at runtime
I've got an interesting problem that's cropped up in a sort of pass based
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which
I've got an Ajax.BeginForm on my page which on success should run a javascript
This is an interesting problem... I've got an ASP.NET 3.5 web application. It's relatively

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.