Visualizzazione dei risultati da 1 a 10 su 10

Discussione: Sessioni.

  1. #1
    Utente bannato
    Registrato dal
    Nov 2000
    Messaggi
    374

    Sessioni.

    Ciao a tutti, se lancio index.php mi ritorna questo errore:

    Notice: Undefined index: sid in d:\programmi\easyphp1-8\www\cms\lib\session.php on line 33

    Notice: Undefined index: PHPSESSID in d:\programmi\easyphp1-8\www\cms\lib\session.php on line 36

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\programmi\easyphp1-8\www\cms\lib\session.php:33) in d:\programmi\easyphp1-8\www\cms\lib\session.php on line 41

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\programmi\easyphp1-8\www\cms\lib\session.php:33) in d:\programmi\easyphp1-8\www\cms\lib\session.php on line 41

    Notice: Undefined index: cms_userid in d:\programmi\easyphp1-8\www\cms\lib\session.php on line 43

    Notice: Undefined index: pk in d:\programmi\easyphp1-8\www\cms\index.php on line 59

    Notice: Undefined index: pageid in d:\programmi\easyphp1-8\www\cms\index.php on line 65

    Warning: mysql_connect(): Accesso non consentito per l'utente: 'fabio'@'localhost' (Password: NO) in d:\programmi\easyphp1-8\www\cms\lib\database.php on line 45

    Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in d:\programmi\easyphp1-8\www\cms\lib\database.php on line 46

    Fatal error: Call to undefined function: show_error() in d:\programmi\easyphp1-8\www\cms\lib\database.php on line 48

    Non riesco a capire qual'è il problema.
    Grazie.

  2. #2
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    è dovuto al fatto che cerca di accedere ad un index inesistente in qualche array (probabilmente $_GET), e siccome non esiste l'indice rilascia un errore.
    Rilasciando l'errore comincia l'output della pagina, e quindi non riesce più ad avviare la sessione.
    La soluzione è quella di testare l'esistenza dell'indice e poi verificare se contiene il dato che cerchi.

    Ad esempio se c'è un istruzione del genere:
    codice:
    $id = $_GET['PHPSESSID'];
    metti
    codice:
    if(isset($_GET['PHPSESSID'])) {
      $id = $_GET['PHPSESSID'];
    }
    ciao ciao

  3. #3
    Utente bannato
    Registrato dal
    Nov 2000
    Messaggi
    374
    Grazie, ora provo.
    quello che mi lascia perplesso eè che ha funzionato fino a poco tempo fa.

  4. #4
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    Originariamente inviato da iif
    Grazie, ora provo.
    quello che mi lascia perplesso eè che ha funzionato fino a poco tempo fa.
    probabilmente hanno fatto un upgrade del php sul server, ed è stato cambiato il livello di error_reporting.

    Solitamente quel tipo di errore non rilascia output (nelle configurazioni + comuni), per esempio su easyphp invece è configurato per rilasciare il warning.

    ciao

  5. #5
    Utente bannato
    Registrato dal
    Nov 2000
    Messaggi
    374
    sto eseguendo le prove su localhost.

  6. #6
    Utente bannato
    Registrato dal
    Nov 2000
    Messaggi
    374
    Originariamente inviato da gianiaz
    è dovuto al fatto che cerca di accedere ad un index inesistente in qualche array (probabilmente $_GET), e siccome non esiste l'indice rilascia un errore.
    Rilasciando l'errore comincia l'output della pagina, e quindi non riesce più ad avviare la sessione.
    La soluzione è quella di testare l'esistenza dell'indice e poi verificare se contiene il dato che cerchi.

    Ad esempio se c'è un istruzione del genere:
    codice:
    $id = $_GET['PHPSESSID'];
    metti
    codice:
    if(isset($_GET['PHPSESSID'])) {
      $id = $_GET['PHPSESSID'];
    }


    Niente da fare, stesso errore.

    ciao ciao

  7. #7
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120
    Potresti postare il codice di questo session.php magari... no?

  8. #8
    Utente bannato
    Registrato dal
    Nov 2000
    Messaggi
    374
    Eccolo:

    <?php
    /*
    #================================================= ==========================
    #= Project: CMS Content Management System
    #= File : session.php
    #= Version: 0.4.9 (2005-05-10)
    #= Author : Jonathan Beckett
    #= Email : jonbeckett@pluggedout.com
    #= Website: http://www.pluggedout.com/index.php?pk=dev_cms
    #= Support: http://www.pluggedout.com/developmen...forum.php?f=14
    #================================================= ==========================
    #= Copyright (c) 2004 Jonathan Beckett
    #= You are free to use and modify this script as long as this header
    #= section stays intact. This file is part of CMS.
    #=
    #= 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 2 of the License, or
    #= (at your option) 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 BLOG files; if not, write to the Free Software
    #= Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    #================================================= ==========================
    */

    // Get the session ID from the URL
    if ($_GET["sid"]!=""){
    session_id($_GET["sid"]);
    }
    if ($_GET["PHPSESSID"]!=""){
    session_id($_GET["PHPSESSID"]);
    }

    // start a session if one is not already started
    session_start();

    if ($_SESSION["cms_userid"]==""){
    $_SESSION["cms_username"]="guest";
    $_SESSION["cms_userid"]=1;
    }

    // Function : form_url
    // Description : Makes a URL with the session ID in it.
    // Arguments : $url - a universal resource locator
    // Returns : a url
    // Author : Jonathan Beckett
    // Last Change : 2003-11-11
    function form_url($url){
    // put the session id in the URL if it is not already there
    if (ereg("sid",$url) || ereg("PHPSESSID",$url)){
    // sid is already there
    $result = $url;
    } else {
    // put the sid in
    if (ereg("\?",$url)){
    $connector = "&";
    } else {
    $connector = "?";
    }
    $result = $url.$connector."sid=".session_id();
    }
    return $result;
    }

    ?>

  9. #9
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120
    Se hai sostituito l'istruzione indicata da gianiaz e anche l'altra simile, non ti può dare gli stessi errori

  10. #10
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    434
    <?php
    /*
    #=======================================
    ====================================
    #= Project: CMS Content Management System
    #= File : session.php
    #= Version: 0.4.9 (2005-05-10)
    #= Author : Jonathan Beckett
    #= Email : jonbeckett@pluggedout.com
    #= Website: http://www.pluggedout.com/index.php?pk=dev_cms
    #= Support: http://www.pluggedout.com/developme...wforum.php?f=14
    #=======================================
    ====================================
    #= Copyright (c) 2004 Jonathan Beckett
    #= You are free to use and modify this script as long as this header
    #= section stays intact. This file is part of CMS.
    #=
    #= 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 2 of the License, or
    #= (at your option) 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 BLOG files; if not, write to the Free Software
    #= Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    #=======================================
    ====================================
    */

    // Get the session ID from the URL
    if (isset($_GET["sid"]) && @$_GET['sid'] != ""){
    session_id($_GET["sid"]);
    }
    if (isset($_GET["PHPSESSID"]) && @$_GET['PHPSESSID'] != ""){
    session_id($_GET["PHPSESSID"]);
    }

    // start a session if one is not already started
    session_start();

    if ($_SESSION["cms_userid"]==""){
    $_SESSION["cms_username"]="guest";
    $_SESSION["cms_userid"]=1;
    }

    // Function : form_url
    // Description : Makes a URL with the session ID in it.
    // Arguments : $url - a universal resource locator
    // Returns : a url
    // Author : Jonathan Beckett
    // Last Change : 2003-11-11
    function form_url($url){
    // put the session id in the URL if it is not already there
    if (ereg("sid",$url) || ereg("PHPSESSID",$url)){
    // sid is already there
    $result = $url;
    } else {
    // put the sid in
    if (ereg("\?",$url)){
    $connector = "&";
    } else {
    $connector = "?";
    }
    $result = $url.$connector."sid=".session_id();
    }
    return $result;
    }

    ?>

    ciao e buon natale

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.