Advanced Search

Results 1 to 4 of 4

Thread: PHP Session isset, help please

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Session isset, help please

    I'm new to PHP and have been playing with sessions.

    Below is what I'm trying to achieve but as it stands I can't get <?php echo ($_SESSION['run']);?> to populate in the if statement. I know it's because it's already set in a php command and uses hyphens. Is there a simple command I can use to get it included?

    Code:
    <?
    if(isset($_SESSION['run']))
    $_SESSION['run']='<tr class="row"><td class="arrow"><img src="images/arrow4.png"></td><td><?php echo ($_SESSION['run']);?></td></tr>';
    else
    $_SESSION['run']='<tr class="row"><td class="arrow"><img src="/images/add1.png"></td><td><a href="/">Run...</a></td></tr>';
    echo ($_SESSION['run']);
    ?>

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    243
    Thanks
    1
    Thanked 18 Times in 18 Posts

    Default

    Do you have session_start(); at the very top of every page that is using the session?

  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    @fastsol1 Yeah I do. It works fine if I don't use the table elements but as you can see I need it all to change.
    Any ideas?

  4. #4
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok so I've made a step forward

    Code:
    <?
    if(isset($_SESSION['run']))
    $_SESSION['run']='<tr class="row"><td class="arrow"><img src="images/arrow4.png"></td><td>' . $_SESSION['run'] . '</td></tr>';
    else
    $_SESSION['run']='<tr class="row"><td class="arrow"><img src="/images/add1.png"></td><td><a href="/">Run...</a></td></tr>';
    echo ($_SESSION['run']);
    ?>
    It now populates but when I refresh it adds a new empty table row. Any ideas?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •