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

giumazzi

Utente Attivo
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.046
150
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

Utente Attivo
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.046
150
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.046
150
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
 
Discussioni simili
Autore Titolo Forum Risposte Data
K [php] Problema con inner join PHP 4
K [PHP] Problema con variabili concatenate. PHP 1
T ALTRO PROBLEMA CON ARRAY PHP PHP 1
D problema php mysql PHP 1
D problema php mysql PHP 1
Z Problema di sincronizzazione PAYPAL con PHP PHP 1
A Problema checkout carrello php PHP 2
G Problema caricamento tabelle MySql da PhP PHP 0
M Problema con php per calcolo costo percentuale PHP 7
O Problema Formmail in PHP su Aruba PHP 0
WebmasterFioriniAndrea Chat e php [problema] PHP 3
L [PHP] Problema con Telegram PHP 1
WebmasterFioriniAndrea [PHP] Problema che non mi fa vedere niente PHP 2
K Help: problema con uno script di booking in php! PHP 0
A [PHP] Problema query insert [RISOLTO] PHP 14
N [Apache] problema con estensione php Apache 0
C [PHP] Problema con download file PHP 0
M [PHP] Problema con preg_match PHP 1
gandalf1959 [PHP] problema con l'utilizzo di Header PHP 3
K [RISOLTO] Problema Griglia Php+Mysql PHP 13
M [PHP] Problema con query select PHP 2
L Problema jQuery validation AJAX (PHP 7) PHP 6
L Problema funzione mail() PHP PHP 3
S [PHP] Problema con istruzione "use" PHP 23
A Problema PHP PHP 1
T [php] problema creazione query select-where PHP 5
M [PHP] problema if PHP 3
L [PHP] Problema su codice o server PHP 5
T [PHP] problema maggiore e minore PHP 4
Cosina [PHP] fwrite problema con le parole accentate PHP 9
M [PHP] Problema search form PHP 3
F [PHP] Problema con number_format PHP 3
L [PHP] problema count messo in una funzione. PHP 1
P [PHP] Progettino CRUD di esercitazione. Problema su $_FILE. PHP 9
trattorino [PHP] problema entrata immagini insert PHP 1
C Apache Cordova problema con php Programmazione 1
trattorino problema raccapricciante php conteggio query PHP 4
T PHP+MYSQL: problema con quelle maledette lettere accentate... PHP 5
F [PHP] Problema con array multidimensionale PHP 4
F Problema con pagine login in PHP PHP 2
M [PHP] Problema script ricezione e invio posta... PHP 1
Kolop [RISOLTO][PHP] Problema Pagination PHP 2
C [PHP] Problema Invio Email Elseif PHP 2
A [PHP] Problema invio mail con funzione mail() PHP 3
gandalf1959 problema con la codifica caratteri accentati e speciali tra php e mysql PHP 3
L [PHP] Problema Script 'Not Found' PHP 4
webmachine [PHP][MYSQL] Problema con le SELECT PHP 5
alessandra86 [PHP] Popolamento database con form ricorsivi - problema array (foreach ) PHP 5
MattiaBL [PHP] Problema ciclo while PHP 3
dvdscr [PHP] Problema malfunzionamento Wordpress WordPress 13

Discussioni simili