Original message
From: Christian Haines [EMAIL PROTECTED]
Date: Thu, Sep 06, 2001 at 03:15:05AM +1030
Message-ID: [EMAIL PROTECTED]
Subject: [PHP] session - why does this not work?
hi all,
any ideas why this does not work? its just a simple script to test
multi-dimensional arrays. the count value should increment...should it not?
many thanks in advance!
?
session_start();
session_register(count[0]);
$count[0]++;
echo $count[0].brnbsp;br;
reset ($HTTP_SESSION_VARS);
while (list($key, $value) = each ($HTTP_SESSION_VARS)) {
echo Key: $key; Value: $valuebr\n;
}
?
html
body
form name=test method=post action=session_test.php
input name=submit type=submit
/form
/body
/html
/Original message
Reply
Try this instead:
session_start();
session_register(count);
$count = array();
$count[0]++;
Btw. faik a variable you session_register() will not be available in
the $HTTP_SESSION_VARS before you've left the page. But I'm not
sure, so you should check that out.
You should check $count for existence btw, before you register it as
a session variable. Ca. it's already registered as a session
variable. Then you don't want to register it again.
And besides that, what would you think of initializing variables? I
mean... you increase $count[0], but from which value? I'd say
something like this:
--- PHP code ---
session_start();
if (!isset ($count)) {
$count = array();
$count[0] = 0;
if (!session_is_registered) {
session_register (count);
}
}
$count[0]++;
--- End of PHP code ---
/Reply
--
* RzE:
--
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]