0

I'm encountering the below error and checked the code (I'm not an expert, rather a beginner)

Some one please help with this.

Err Msg:

( ! ) Fatal error: Call to undefined function session_register() in C:\wamp\www\11\session.php on line 3


Call Stack


>#

>Time

>Memory

>Function

>Location

>1 0.0030 179560 {main}( ) ..\index.php:0 
>2 0.0060 237472 include_once( 'C:\wamp\www\11\template.php' ) ..\index.php:342 
>3 0.0740 254304 include_once( 'C:\wamp\www\11\session.php' ) ..\template.php:3 

Index-PHP (starting)

<?php 
function main()
{
$config=mysql_fetch_array(mysql_query("select * from sbjbs_config"));
$policies=mysql_fetch_array(mysql_query("select * from sbjbs_policies"));
$cid=0;

    $suspended_list="-1";
    $mem_q=mysql_query("select * from sbjbs_employers where sb_suspended='yes'");
    while($mem=mysql_fetch_array($mem_q))
    { $suspended_list.=",".$mem["sb_id"];}

    $disapproved_list="-1";
    $comp_q=mysql_query("select * from sbjbs_companies where 
    (sb_approved='no' OR sb_uid in ($suspended_list))");
    while($comp=mysql_fetch_array($comp_q))
    { $disapproved_list.=",".$comp["sb_id"];}

?>
<table width="100%" border="0" cellspacing="10" cellpadding="2" class="maintablestyle">
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
        <tr> 
          <form name="form1" method="post" action="search_result.php">
            <td align="center" valign="middle" class="innertablestyle"><br> <input name="keyword" type="text" size="40"> 
              &nbsp;&nbsp; <select name="loc_id">
                <option value="" selected>Any Location</option>
                <?php
                $loc_query=mysql_query("select * from sbjbs_locations where sb_pid=0 order by sb_default desc,sb_loc_name");
                while($loc=mysql_fetch_array($loc_query))
                {
                ?>
                <option value="<?php echo $loc["sb_id"];?>"><?php echo $loc["sb_loc_name"];
                ?></option>
                <?php 
                }
                ?>

Line 343 in Index-PHP File

    <?php
}
include_once ('template.php');
?>

Sessions-php File

    <?php
session_start();
session_register("sbjbs_username");
session_register("sbjbs_userid");
session_register("sbjbs_memtype");
session_register("sbjbs_emp_username");
session_register("sbjbs_emp_userid");
//session_register("ID");
?>

Some one please help me thru with this...; Thanks in advance

animuson
  • 52,378
  • 28
  • 138
  • 145

3 Answers3

3

session_register() has been deprecated see manual for further

use variables with $_SESSION['var'] = "value"

For more info :- How to fix the session_register() deprecated issue?

and error causing on server with different php version

try

session_start();
$_SESSION["sbjbs_username"] = 'value';
$_SESSION["sbjbs_userid"] = 'value'; 

and so on

Community
  • 1
  • 1
Rakesh Sharma
  • 13,570
  • 4
  • 35
  • 42
1
session_register("sbjbs_username");

This is not the most correct way to do.. the function session_register() has been deprecated a long time ago... you should do this:

$_SESSION['sbjbs_username'] = 'something';
stackrocha
  • 415
  • 2
  • 8
  • Hi I'm only in the learning stage, can you please help me in correcting this err, as I'm still getting an error..... – user3563793 Apr 23 '14 at 09:36
  • 1
    Thank you my friends..... I simply commented all those codes and is working now, LOL Dumb me.... I'm stuck with for the past 3 days HAHA thank you guys – user3563793 Apr 23 '14 at 09:38
  • Comment this `session_register("sbjbs_username"); session_register("sbjbs_userid"); session_register("sbjbs_memtype"); session_register("sbjbs_emp_username"); session_register("sbjbs_emp_userid");` in your Sessions-php File and see if you get the same error.. – stackrocha Apr 23 '14 at 09:38
  • You're welcome.. You can vote as a correct answer if you like. – stackrocha Apr 23 '14 at 09:40
0

session_register() has been deprecated and you no longer need to register variables You can easily use $_SESSION['variablename'] for session variables.

Example:

$_SESSION["ID"]=$id;
$_SESSION["name"]=$name;

See an guide here.