+ Reply to Thread
Results 1 to 3 of 3

Thread: PHP Sessions : Error?!?

  1. #1
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    PHP Sessions : Error?!?

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
    Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/zenax/public_html/index.php:17) in /home/zenax/public_html/index.php on line 45
    Both appear after loggin in:

    I recieved this when running a script. I am not entirely sure what it means or anything. All I know is that my script ran fine, and this is the first time I have updated the script, even though I have not changed anything regarding the sessions.

    I am not complaining as I can run it on my machine, I was just letting you know what I recieved.

    Many Kind regards,
    Zenax

    EDIT: Amended script using a different way of creating the sessions. This removed the error messages. They only seem to appear when using the session_register function.

    Original Script:
    PHP Code:
                <?php

            
    // Require once the DB script
            
    require_once('connect_db.php');

            
    $username $_POST['username'];
            
    $password $_POST['password'];

            
    // Creating an SQL Query
            
    $q "SELECT * FROM users WHERE  users = '$username' and password = '$password'";
            
    $check mysql_query($q);

            
    // Counting the table row
            // If the result is matched then $username, $password must be row 1
            
    $count mysql_num_rows($check);

            
    // Performing login
            
    if ($count == 1)    {

                
    session_register('username');
                
    session_register('password');
                echo 
    'Welcome '$_SESSION['username'] .'You are now logged in!';

                }    else    {

                    echo 
    'Wrong username or password specified';
        }
                
    ?>
    Fixed with:
    PHP Code:
                <?php
            
    // Require once the DB script
            
    require_once('connect_db.php');

            
    $username $_POST['username'];
            
    $password $_POST['password'];

            
    // Creating an SQL Query
            
    $q "SELECT * FROM users WHERE  users = '$username' and password = '$password'";
            
    $check mysql_query($q);

            
    // Counting the table row
            // If the result is matched then $username, $password must be row 1
            
    $count mysql_num_rows($check);

            
    // Performing login
            
    if ($count == 1)    {

                
    $_SESSION['username'] = $username;
                
    $_SESSION['password'] = $password;
                echo 
    'Welcome '$_SESSION['username'] .'You are now logged in!';

                }    else    {

                    echo 
    'Wrong username or password specified';
                          }
                
    ?>
    Just in case you wanted to know how I fixed the problem.
    Last edited by Zenax; 07-04-2007 at 08:06 AM.
    Regards,
    Zenax

  2. #2
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: PHP Sessions : Error?!?

    PHP Code:
    <?php
    session_start
    ();
    ?>
    You didn't need that?
    -Chris Z
    Retired Account Manager


  3. #3
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    Re: PHP Sessions : Error?!?

    nope, for some strange reason it works.

    Try here:
    http://zenax.x10hosting.com/

    use madman as username and the password

    Just thought I would let you know about the session_registered() function not working. It is not essential, as there are other ways around it. Just thought you might want to know this.
    Regards,
    Zenax

+ Reply to Thread

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  4. PHP Error Help
    By Christopher in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 03-29-2007, 03:25 PM
  5. {req} Banners
    By SEŅOR in forum The Marketplace
    Replies: 23
    Last Post: 01-05-2006, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers