Session() help needed...please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Session() help needed...please

Post 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.
jh_1981
Forum Newbie
Posts: 22
Joined: Fri Jan 30, 2009 6:21 pm

Re: Session() help needed...please

Post by jh_1981 »

need session_start()
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Session() help needed...please

Post 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 :)
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Session() help needed...please

Post 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'];
 
 ?>
 
Post Reply