-2

I am getting the following error code:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /srv/disk1/1365341/www/pokeronline.atspace.eu/tables/NewTable.php:1) in /srv/disk1/1365341/www/pokeronline.atspace.eu/tables/NewTable.php on line 2

session_start() is the very first thing in my file. I can't find a solution to it, I already spent like 3 hours trying to figure it out.

<?php
    session_start();
    require 'config.php';
    ?>
    <?php



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="cache-control" content="no-cache" />
<title>NewTable</title>
<style type="text/css">

</style></head>

<body>


</body>
</html>

Config.php

<?php
/**
 * Config and making connection
 */
$cfg['db_server'] = 'xxx'; // db server
$cfg['db_user'] = 'xxx'; // user name
$cfg['db_pass'] = 'xxx'; // pass
$cfg['db_name'] = 'xxx'; // DB name

//connect to database
$conn = @mysql_connect ($cfg['db_server'], $cfg['db_user'], $cfg['db_pass']);
$select = @mysql_select_db ($cfg['db_name'], $conn);

if (!$conn) {
    die ('<p class="error">Unable o connect to the database</p>');
}

if (!$select) {
    die ('<p class="error">Unable o connect to the database</p>');

Can somebody help?

@EDIT: FIXED.I created another php file, opened it in a different editor ( Adobe Dreamweaver in my case) and saved the file again. Before I used "all types" and wrote NewTable.php . Now I used php files from the list, and unchecked the include BOM tick box. Works perfectly now. Thank you all for time taken to help and I really appreciate it.

pokrak94
  • 198
  • 1
  • 4
  • 20
  • 3
    -1 for [lack of research](http://stackoverflow.com/search?q=headers+already+sent) – meda Apr 26 '14 at 14:36
  • Any invisible characters like a BOM? – Sirko Apr 26 '14 at 14:36
  • @meda Read before you judge. I SAID I DIDN'T FIND ANYTHING USEFUL this means I have tried some of those researches and they DID NOT work. Sirko I saved them in ANSI and in utf-8 without BOM using notepad++. Strange thin is that the same lines of code worked before hand in different files. Somehow they don't now... – pokrak94 Apr 26 '14 at 14:58
  • Dont take offense, what is inside of config.php – meda Apr 26 '14 at 15:03
  • Unable o connect to the database'); } if (!$select) { die ('

    Unable o connect to the database

    ');
    – pokrak94 Apr 26 '14 at 15:07
  • I used 'at" because the webpage won't let me "notify more than one user" – pokrak94 Apr 26 '14 at 15:08

3 Answers3

0

How to fix "Headers already sent" error in PHP

Output can be:

Unintentional:

  • Whitespace before <?php or after ?>
  • UTF-8 Byte Order Mark
  • Previous error messages or notices

Intentional:

  • print, echo and other functions producing output (like var_dump)
  • Raw areas before

You should definitely read the article about regarding output buffering. Still there is a quickfix: turn on phps output buffering. E.G. ini_set('output_buffering', 'On');.

http://www.wallpaperama.com/forums/php-how-to-enable-output-buffering-in-php-ini-file-gallery-settings-code-t413.html

  • there is no white spaces after or before . What's the sotry with that UTF-8 Order Mark? I couldn't find anything useful on the web. What do you mean by previous error messages? If my understanding is right, you are asking about error in previous pages. There are not any. – pokrak94 Apr 26 '14 at 14:42
  • Edited the answer. Try `ini_set('output_buffering','On');` – Andreas Storvik Strauman Apr 26 '14 at 14:49
0

Try

   <?php session_start();
        require 'config.php';
        ?>
0
<?php
    session_start();
    require 'config.php';
    ?>
    <?php


?>

This thing makes no sense! just write following:

<?php
  session_start();
  require_once("config.php");
?>

And save you .php file as ANSI that should work ;)

petritz
  • 182
  • 1
  • 9