7 Replies Latest reply: Apr 13, 2012 10:48 AM by Jonathan Fortis RSS

    login script Warning error session_start()

    Jonathan Fortis Community Member

      I have used the login behavior in dreamweaver and when i run the page it give the following error

       

       

      Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/users1/jonfort/public_html/think/beta/index.php:263) in/usr/users1/jonfort/public_html/think/beta/index.phpon line 474

       

       

      i have looked at the error line   session_start();

       

      the rouble is the form is in a template and used across the whole site. i have placed the php in the body of the page so it will carry across all the pages and the error is pointing to the line that is locked

       

      has anyone else had this problem and how do you overcome it

       

       

      thanks in advance

        • 1. Re: login script Warning error session_start()
          Jonathan Fortis Community Member

          i tryed putting the code at the start of one of the pages and got the following error

           

          Fatal error: Call to undefined function: getsqlvaluestring() in /usr/users1/jonfort/public_html/think/beta/index.php on line 23

           

           

          the code is

           

          GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

          • 2. Re: login script Warning error session_start()
            Ben Pleysier MVP

            Cannot send session cache limiter - headers already sent (output started at /usr/users1/jonfort/public_html/think/beta/index.php:263) in/usr/users1/jonfort/public_html/think/beta/index.phpon line 474

            This says that you have already had an output which started on line 263.

             

            If you have a look here http://forums.adobe.com/message/4332163#4332163 you will see that I placed the session_id and session_start at the very top of the page when no output has occurred.

             

            session_start() must be repeated on each page that requires the session variables.

             

            Gramps

            • 3. Re: login script Warning error session_start()
              Jonathan Fortis Community Member

              i placed this whole code at the top of the page

               

              <?php

              // *** Validate request to login to this site.

              if (!isset($_SESSION)) {

                session_start();

              }

               

               

              $loginFormAction = $_SERVER['PHP_SELF'];

              if (isset($_GET['accesscheck'])) {

                $_SESSION['PrevUrl'] = $_GET['accesscheck'];

              }

               

               

              if (isset($_POST['userid'])) {

                $loginUsername=$_POST['userid'];

                $password=$_POST['password'];

                $MM_fldUserAuthorization = "";

                $MM_redirectLoginSuccess = "php.php";

                $MM_redirectLoginFailed = "failed.php";

                $MM_redirecttoReferrer = false;

                mysql_select_db($database_hostprop, $hostprop);

               

                $LoginRS__query=sprintf("SELECT userid, password FROM think_signup WHERE userid=%s AND password=%s",

                  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

                

                $LoginRS = mysql_query($LoginRS__query, $hostprop) or die(mysql_error());

                $loginFoundUser = mysql_num_rows($LoginRS);

                if ($loginFoundUser) {

                   $loginStrGroup = "";

                 

                        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}

                  //declare two session variables and assign them

                  $_SESSION['MM_Username'] = $loginUsername;

                  $_SESSION['MM_UserGroup'] = $loginStrGroup;               

               

               

                  if (isset($_SESSION['PrevUrl']) && false) {

                    $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];

                  }

                  header("Location: " . $MM_redirectLoginSuccess );

                }

                else {

                  header("Location: ". $MM_redirectLoginFailed );

                }

              }

              ?>

               

              and it returned the error

               

              GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

              • 4. Re: login script Warning error session_start()
                Ben Pleysier MVP

                Is 'userid' text or an integer?

                 

                Gramps

                • 5. Re: login script Warning error session_start()
                  Jonathan Fortis Community Member
                  varchar(55)

                   

                  varchar as it is a name (text)

                  • 6. Re: login script Warning error session_start()
                    Ben M MVP

                    The problem is not with the data.  Quite simply the function is not defined.  DW usually puts some code like:

                     

                    if (!function_exists("GetSQLValueString")) {

                    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

                    {

                      if (PHP_VERSION < 6) {

                        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

                      }

                    Up at the top of the PHP file and that is missing from yours.

                    • 7. Re: login script Warning error session_start()
                      Jonathan Fortis Community Member

                      so what should i do about the missing code?