Page 1 of 1

Session() help needed...please

Posted: Tue Mar 17, 2009 12:11 pm
by nishmgopal
HI guys, I am assigning my session like this:

Code: Select all

 
$sql="SELECT * FROM Job_ID WHERE Job_Name='$projectname'";
$result = mysql_query($sql) or die ("Couldn't execute query.");
 
while ($row=mysql_fetch_array($result))
 
$Job_ID=$row['Job_ID'];
{
if(isset($_POST['Job_ID']))
       {
        $_SESSION['Job_ID']=$Job_ID; 
        }
}
[code]
 
and at the top of this page I have session_start();.
 
On the other pages, where I want to use this job id variable I have got:
 
[code=php]
  <?php
 
 session_start();
 if(isset( $_SESSION['Job_ID']))
 {
  $_SESSION['Job_ID']=$Job_ID;
 }
 echo $_SESSION['Job_ID'];
 
 ?>
 
But it doesnt echo anything and when I try to use the $_SESSION['Job_ID'] variable nothing is returned. Can someone please help.

Re: Session() help needed...please

Posted: Tue Mar 17, 2009 12:46 pm
by jh_1981
need session_start()

Re: Session() help needed...please

Posted: Tue Mar 17, 2009 6:20 pm
by php_east
nishmgopal wrote: and at the top of this page I have session_start();.
 
On the other pages, where I want to use this job id variable I have got:
 

Code: Select all

 
  <?php
 
 session_start();
 if(isset( $_SESSION['Job_ID']))
 {
  $_SESSION['Job_ID']=$Job_ID;
 }
 echo $_SESSION['Job_ID'];
 
 ?>
 
But it doesnt echo anything and when I try to use the $_SESSION['Job_ID'] variable nothing is returned. Can someone please help.
you mean to say, on the other pages where you want to use this job id, you set the session job id, which already has a value, to the var job id, which has nothing, and then you echo session id, and expect something.

i think you are being a little bit unfair to php :)

Re: Session() help needed...please

Posted: Wed Mar 18, 2009 2:18 am
by susrisha

Code: Select all

 
On the other pages, where I want to use this job id variable I have got:
 
[code=php]
  <?php
 
 session_start();
 if(isset( $_SESSION['Job_ID']))
 {
 [color=#FF0000] $_SESSION['Job_ID']=$Job_ID;[/color]
  $Job_ID = $_SESSION['Job_ID'];
 }
 echo $_SESSION['Job_ID'];
 
 ?>