Page 1 of 1

PHP script dies setting key => value

PostPosted: 29. December 2010 20:51
by ElfN
I've got a foreach loop the takes the session array and parses it into key and value. It works fine online but doesn't locally. Is there something in the config file I should be setting for this?

Code: Select all
foreach($_SESSION as $key => $value) {
   $message.="<br>$key = $value";
}


When I view the page I get this bit at the top

Code: Select all
$value) { $message.="
$key = $value"; } $message.="
Sessions are being unset."; $_SESSION=array(); } if (!isset($_SESSION['siteusid'])) { $_SESSION['siteusid']=$siteid; $_SESSION['level']="admin"; } ?>


which tells me it's the => that's causing the break. ?

Thanks.

Re: PHP script dies setting key => value

PostPosted: 29. December 2010 21:02
by Sharley
ElfN wrote:It works fine online but doesn't locally.
XAMPP 1.7.3 has short_open_tag set Off by default in the php.ini file - perhaps this may be an issue here?
<? and ?>

Required unless set to On, not recommended, see php.ini comment.
<?php and ?>

Re: PHP script dies setting key => value

PostPosted: 29. December 2010 21:05
by ElfN
Not an issue. All the coding for AdminHeader.php is set to <?php and ?>. That would have been an easy fix, but no cigar.

Re: PHP script dies setting key => value

PostPosted: 29. December 2010 22:23
by WilliL
ElfN wrote:
Code: Select all
foreach($_SESSION as $key => $value) {
   $message.="<br>$key = $value";
}


this works on my XAMPP 1.7.3 (when I rember right there "$k = $v" does only work when they are strings not arrays, but I'm not sure ..)
Code: Select all
foreach($array as $key => $value){
  $message .= "<br>".$key." = ".$value;
}


if it's a mixed script (html and php parts) I would seach for '<?' to be sure that everywhere correct writing used. I've sen some scripts where both writings '<?php' and '<?' were used :shock:

Re: PHP script dies setting key => value

PostPosted: 29. December 2010 22:40
by ElfN
<blushes in embarrassment> Yeah, found it. <sigh> Thanks.