PHP script dies setting key => value

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP script dies setting key => value

Postby ElfN » 29. December 2010 20:51

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.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP script dies setting key => value

Postby Sharley » 29. December 2010 21:02

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 ?>
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP script dies setting key => value

Postby ElfN » 29. December 2010 21:05

Not an issue. All the coding for AdminHeader.php is set to <?php and ?>. That would have been an easy fix, but no cigar.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP script dies setting key => value

Postby WilliL » 29. December 2010 22:23

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:
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP script dies setting key => value

Postby ElfN » 29. December 2010 22:40

<blushes in embarrassment> Yeah, found it. <sigh> Thanks.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 146 guests