Log in

View Full Version : PHP Session isset, help please



gravy834
02-15-2011, 11:37 AM
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?



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

fastsol1
02-15-2011, 12:06 PM
Do you have session_start(); at the very top of every page that is using the session?

gravy834
02-15-2011, 12:08 PM
@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?

gravy834
02-15-2011, 12:32 PM
Ok so I've made a step forward



<?
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?