0

I got a problem that I can't solve despite searching for answer. It's the code of the index.php:

<?php
session_start();
?>
<html>
<head>
<title>Elektromechanika Pojazdowa</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head>
<body bgcolor="#170266">
    <center>
        <div id="naglowek">ELEKTROMECHANIKA POJAZDOWA</div>
        <div id="menu">
            <table width="100%">
                <tr>
                    <td width="50%">
                        <a class="menu" href="index.php?p=main">Strona Główna</a>
                    </td>
                    <td width="50%">
                        <a class="menu" href="index.php?p=contact">Kontakt</a>
                    </td>
                </tr>
            </table>
        </div>
    </center>
    <?php
        $p = $_GET['p'];
        if(!empty($p))
        include("$p".'.php');
        else
        include('main.php');
    ?>
    <div id="stopka">
        <center>
            <table>
                <tr>
                    <td width="30%">
            <center><img src="img/bendiks.jpg"></center>
                    </td>
                    <td width="30%">
            <center><img src="img/magneti marelli.jpg" width="300px"     height="170px"></center>
                    </td>
                    <td width="30%">
            <center><img src="img/bosch.jpeg"></center>
                    </td>
                </tr>
            </table>
        </center>
    </div>
    <div id="link">
        <a class="admin" href="index.php?p=admin">Panel adminitracyjny</a>
    </div>

</body>

I can't get it to work, because I get error:

Warning: session_start() [function.session-start]: Cannot send session cookie - 
headers already sent by (output started at D:\Program Files\WebServ\httpd-users\dla 
Gabi\index.php:1) in D:\Program Files\WebServ\httpd-users\dla Gabi\index.php on line 2

I tried using ob_start(); but it just doesn't work. I don't understand why there is a problem, cause session_start(); is the first function, placed even before any html code..

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
Arkadiusz Galler
  • 153
  • 1
  • 1
  • 8

2 Answers2

0
Enable ob_start in php.ini file
<?php
session_start();
ini_set("ob_start","On");

?>
Punitha
  • 152
  • 1
  • 12
0

To get to the php.ini on the external hosting server, I think you need to set up a Virtual Private Server (VPS). At least from the problems I myself encountered with the lack of a custom php.ini file on our hosting server, we needed a VPS in order to use our own ini files for the php protocol.

Sean Limpens
  • 79
  • 1
  • 1
  • 12