[PHP] Problema - Warning: session_start() [function.session-start]

giumazzi

Nuovo Utente
16 Feb 2017
27
2
3
provincia PESARO
Ricevo il seguente warning appena mi collego alla pagina index.php
Codice:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ilguitto/domains/ilguitto.org/public_html/book/index.php:14) in /home/ilguitto/domains/ilguitto.org/public_html/book/index.php on line 27

Qui sotto il codice completo della pagina index.php

Codice:
1 <!--
2 
3 <Ticket-Booking>
4 Copyright (C) <2013>   
5 <Abhijeet Ashok Muneshwar>
6 <[email protected]>
7 
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11  any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 
21 -->
22
23 <!DOCTYPE HTML>
24
25 <?php
26     include('db_login.php');
27     session_start();
28     $connection = mysql_connect($db_host, $db_username, $db_password);
29     if (!$connection)
30     {
31         die ("Could not connect to the database: <br />". mysql_error());
32     }
33     mysql_select_db('book');
34 ?>
35
36 <HTML>
37
38     <HEAD>
39         <meta charset="utf-8">
40         <meta name="viewport" content="width=device-width, initial-scale=1.0">
41         <title>Bus Ticket Booking</title>
42         <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
43         <link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css">
44         <link rel="stylesheet" type="text/css" href="css/datepicker.css" />
45     </HEAD>
46
47     <BODY>
48         <br /><br /><br />
49         <div class="container">
50             <div class="row well">
51                 <div class="span10">
52                     <form action="seat.php" method="POST">
53                         <center>
54                             <label>Date of Journey</label>
55  
56
57
58                             <div data-date-format="yyyy-mm-dd" data-date="document.write(date())" class="input-append date myDatepicker">
59                                 <input type="text" value="" name="doj" size="16" class="span2" required>
60                                 <span class="add-on"><i class="icon-calendar"></i></span>
61                             </div>
62
63
64                             <!--<input type="date" class="span2" name="doj" placeholder="YYYY-MM-DD" required/>-->
65                             <br><br>
66                             <button type="submit" class="btn btn-info">
67                                 <i class="icon-ok icon-white"></i> Submit
68                             </button>
69                             <button type="reset" class="btn">
70                                 <i class="icon-refresh icon-black"></i> Clear
71                             </button>
72                             <a href="./login.php" class="btn btn-danger"><i class="icon-remove icon-white"></i> Cancel Ticket </a>
73                         </center>
74                     </form>
75                 </div>
76             </div>
77         </div>
78
79         <script src="http://code.jquery.com/jquery-latest.min.js"></script>
80         <script>window.jQuery || document.write('<script src="js/jquery-latest.min.js">\x3C/script>')</script>
81         <script type="text/javascript" src="js/bootstrap.js"></script>
82         <script type="text/javascript" src="js/bootstrap-datepicker.js"></script>
83         <script>
84             $('.myDatepicker').each(function() {
85                 var minDate = new Date();
86                 minDate.setHours(0);
87                 minDate.setMinutes(0);
88                 minDate.setSeconds(0,0);
89                 
90                 var $picker = $(this);
91                 $picker.datepicker();
92                 
93                 var pickerObject = $picker.data('datepicker');
94                 
95                 $picker.on('changeDate', function(ev){
96                     if (ev.date.valueOf() < minDate.valueOf()){
97                         
98                         // Handle previous date
99                         alert('You can not select past date.');
100                         pickerObject.setValue(minDate);
101                         
102                         // And this for later versions (in case)
103                         ev.preventDefault();
104                         return false;
105                     }
106                 });
107             });                     
108         </script>
109     </BODY>
110 </HTML>
qui sotto ancora il codice di db_login.php
Codice:
23 <?php
24     $db_host='localhost';
25     $db_username='abhijeet';
26     $db_password='abhijeet';
27 ?>
Non riesco a trovare la soluzione (ho tolto tutti gli spazi primo di " <? ", etc..)

c'è nessuno che ha rilevato errori simili?

Grazie per l'aiuto
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.042
146
63
PR
www.borgo-italia.it
ciao
attento hai output html prima di session_start (es. <!DOCTYPE HTML> è un output html) e la funzione deve avvenire prima di qualsiasi output
22
23 <!DOCTYPE HTML>
24
25 <?php
26 include('db_login.php');
27 session_start();
28 $connection = mysql_connect($db_host, $db_username, $db_password);
quindi correggi
1 <?php
2 session_start();
3 ?>
4
.....
22
23 <!DOCTYPE HTML>
24
25 <?php
26 include('db_login.php');
27 //session_start();
28 $connection = mysql_connect($db_host, $db_username, $db_password);
.....
evidentemente senza i numeri di riga
 

giumazzi

Nuovo Utente
16 Feb 2017
27
2
3
provincia PESARO
grazie Borgo,
ma purtroppo il problema persiste.

Codice:
<!--
<Ticket-Booking>
Copyright (C) <2013> 
<Abhijeet Ashok Muneshwar>
<[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
 any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<?php
    include('db_login.php');
    session_start();
    $connection = mysql_connect($db_host, $db_username, $db_password);
    if (!$connection)
    {
        die ("Could not connect to the database: <br />". mysql_error());
    }
    mysql_select_db('ilguitto_book');
?>
<!--<!DOCTYPE HTML>-->
<HTML>
    <HEAD>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Bus Ticket Booking</title>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css">
        <link rel="stylesheet" type="text/css" href="css/datepicker.css" />
    </HEAD>

    <BODY>
guarda il.guitto.org/book
c'è qualcos'altro da fare?
 
Ultima modifica:

Oswold

Utente Attivo
7 Ago 2013
81
0
6
Catania
Prova ad inserire session_start() nel seguente modo:

PHP:
<?php
    session_start();
    include('db_login.php');
    $connection = mysql_connect($db_host, $db_username, $db_password);
    if (!$connection)
    {
        die ("Could not connect to the database: <br />". mysql_error());
    }
    mysql_select_db('ilguitto_book');
?>
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.042
146
63
PR
www.borgo-italia.it
ciao
comunque non hai corretto come dicevo: alla riga 1 il tag php, alla riga due session_srat() e alla riga 3 il tag di chiusura di php
alle seguenti tutto il resto e verifica che nel resto un sia rimasto session_start che devi cancellare
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.042
146
63
PR
www.borgo-italia.it
ciao
verifica TUTTE le tue pagine, devi correggere così in tutte dove c'è session_start
PHP:
<?php
session_start();
?>
<!--

<Ticket-Booking>
Copyright (C) <2013> 
<Abhijeet Ashok Muneshwar>
<[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
 any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

-->

<?php
include('db_login.php');
//qui c'era session_start(); ELIMINARE
//...eccetera
?>
ci sono diverse pagine in cui session-start non è alla riga 1