urgent..php error .....tanks in advance

Discussion in 'PHP' started by newbie12345, May 6, 2010.

  1. #1
    my problem is dat im getting when trying to register a session
    the error im getting is

    u have been logged in successfully
    Deprecated: Function session_register() is deprecated in C:\wamp\www\music website\login.php on line 25

    Deprecated: Function session_register() is deprecated in C:\wamp\www\music website\login.php on line 26

    
    include ('connect.php');
    
          $user  = $_POST['u_name'];
          $pass   = $_POST['pwd'];
    	  
    if(!$user){
    echo "please enter your username. <br>";
    }
    if(!$pass){
    	echo "please enter your password";
    	}
    if ($user && $pass){
    	   $sql= ("SELECT * FROM user_accounts WHERE username = '$user' AND password = '$pass'");
    	   $res = mysql_query($sql);
    	   $count = mysql_num_rows($res);
    	   
    	  if ($count ==0){
    	     echo "ur user name or password may be incorrect! try again";
    	  } ELSE {
    	  if ($count ==1){
    	   $row = mysql_fetch_array($res);
    	   echo "u have been logged in successfully";
    	   session_register('user');
    	   session_register('pass');
    
    	   }
    	  }
    
    }
    
    
    PHP:

     
    newbie12345, May 6, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Its a warning not an error, 2 different things.... however, its saying that session_register is deprecated... if you look at the documentation, you will see why;

    http://php.net/manual/en/function.session-register.php
     
    lukeg32, May 7, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Use the $_SESSION array as an alternative.
     
    danx10, May 7, 2010 IP
  4. newbie12345

    newbie12345 Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    [​IMG]
     
    newbie12345, May 7, 2010 IP
  5. lorkan

    lorkan Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Dont forget that it is a good idea to turn error messages of after you are done fixing the problems. Nobody want to see errormsgs unless it is while debugging.

    Good luck!
     
    lorkan, May 7, 2010 IP
  6. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #6
    Whilst debugging/maintenance mode enable all error_reporting/handlers to help debug, but on an active/live site it can be disabled (as it can seem a distraction to visitors) - which means you can log them - that way they don't appear but you get a record of the errors (only viewable by you).

    Alternatively you can still display errors, but customize them to display something prettier than the default, by using the set_error_handler() function.
     
    danx10, May 7, 2010 IP
  7. live.co.uk

    live.co.uk Banned

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    no one using session_register() now
     
    live.co.uk, May 7, 2010 IP
  8. toonboon

    toonboon Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Well apparently he was using it, so that does make your statement false doesn't it :)?
     
    toonboon, May 7, 2010 IP
  9. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #9
    session_register(), session_is_registered() and session_unregister() are dependent on register_globals. Register_globals were turned off starting in php4.2 in the year 2002. No new code should have been written after that point in time that used these functions. These functions have been removed in php6. Any code using them will stop working under php6 and must be changed to use the $_SESSION array variables.

     
    roopajyothi, May 7, 2010 IP