Re: [PHP] SESSION problem
tedd schrieb: Sabine: I understand the problem now. But to get to my basic question to you, namely using this link: http://www.webbytedd.com/b2/session-test1/index.php -- does SESSION[20] and SESSION[test2] show anything in the second step (Step 2) or are the results blank? Oh, ok, when I just call your URL: they are both blank! Cheers, Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hi Tedd, tedd schrieb: At 2:45 PM +0200 8/16/08, Sabine Richter wrote: Yes, our mails overlaped each other (Do you say that in english? My english is not the best.) Sabine: Your English is fine -- much better than my de for certain. Thanks :-) By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP. That's interesting. Let's make sure we're talking about the same thing here. This is the demo: http://www.webbytedd.com/b2/session-test1/index.php In my browser Step 1 shows: SESSION[20] => good morning SESSION[test2] => good night In Step 2: Neither are there. Is that what you see? I tried the script from your first example on http://www.webbytedd.com/b2/session-test/index1.php I just deleted the header and footer includes and set the error reporting to E_ALL. That's what I get: index.php: f411abf8cb6cb7e0f2d091251c1906dd Step 1 -- SESSIONs Recorded 1 = 1 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 8 9 = 9 10 = 10 hello Code: Step 1 -- SESSIONs Recorded "); } echo($_SESSION['test']); ?> Code: Notice: Unknown: Skipping numeric key 1. in Unknown on line 0 Notice: Unknown: Skipping numeric key 2. in Unknown on line 0 Notice: Unknown: Skipping numeric key 3. in Unknown on line 0 Notice: Unknown: Skipping numeric key 4. in Unknown on line 0 Notice: Unknown: Skipping numeric key 5. in Unknown on line 0 Notice: Unknown: Skipping numeric key 6. in Unknown on line 0 Notice: Unknown: Skipping numeric key 7. in Unknown on line 0 Notice: Unknown: Skipping numeric key 8. in Unknown on line 0 Notice: Unknown: Skipping numeric key 9. in Unknown on line 0 Notice: Unknown: Skipping numeric key 10. in Unknown on line 0 index1.php: f411abf8cb6cb7e0f2d091251c1906dd Step 2 -- Results of SESSIONs passed Notice: Undefined offset: 1 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 1 = Notice: Undefined offset: 2 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 2 = Notice: Undefined offset: 3 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 3 = Notice: Undefined offset: 4 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 4 = Notice: Undefined offset: 5 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 5 = Notice: Undefined offset: 6 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 6 = Notice: Undefined offset: 7 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 7 = Notice: Undefined offset: 8 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 8 = Notice: Undefined offset: 9 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 9 = Notice: Undefined offset: 10 in P:\xampp\htdocs\sabine\test_diverse\index1.php on line 21 10 = hello Code: Step 2 -- Results of SESSIONs passed "); } echo($_SESSION['test']); ?> Code: You see, I get the content of $_SESSION['test'] in index1.php. It's the same as in your second example, isn't it? I would try your second example too, but you highlighted the code of index.php in index1.php too. So I can't. Cheers Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hello Tedd, tedd schrieb: At 2:09 PM +0200 8/16/08, Sabine Richter wrote: Hello Tedd, it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION. By assigning it to $_SESSION, you get a Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 and in your second script a Notice: Undefined offset: 1 in yourpath\index1.php on line XX -> whatever line it was in your script If you define $_SESSION['var'.$i] = $i; or $_SESSION[$i.'var'] = $i; or even $_SESSION[$i.'.1'] = $i; the $_SESSION won't forget your vars on the way to script 2. But it's a bit strange, that you can use your numeric keys in script 1. I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names. So, is that a php bug? But as the docu says "A valid variable name starts with a letter or underscore", I think you can not complain about it. Cheers Sabine Sabine: You hit the nail right on the head. I discovered that fact this morning and posted an answer already. Here's the demo: http://www.webbytedd.com/b2/session-test1/index.php Yes, our mails overlaped each other (Do you say that in english? My english is not the best.) I read everything I could find about sessions, but didn't come across: "A valid variable name starts with a letter or underscore" To the contrary, this is only what I found: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores Where did you see that? My citation is just a part of what you found. By the way: I tried your initial code and I had no problem with the variable declared after the numeric ones. (your $_SESSION['test']). I tried on a Version 5.2.5 an Win XP. Cheers, Sabine Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION problem
Hello Tedd, it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION. By assigning it to $_SESSION, you get a Notice: Unknown: Skipping numeric key 1 in Unknown on line 0 and in your second script a Notice: Undefined offset: 1 in yourpath\index1.php on line XX -> whatever line it was in your script If you define $_SESSION['var'.$i] = $i; or $_SESSION[$i.'var'] = $i; or even $_SESSION[$i.'.1'] = $i; the $_SESSION won't forget your vars on the way to script 2. But it's a bit strange, that you can use your numeric keys in script 1. I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names. So, is that a php bug? But as the docu says "A valid variable name starts with a letter or underscore", I think you can not complain about it. Cheers Sabine tedd schrieb: Hi gang: Arrggg -- what the heck is going on? I can't get anything to pass via SESSION -- what's wrong? Here's the example -- (all the code is there): I populate the $_SESSIONs here. http://www.webbytedd.com/b2/session-test/index.php If you click "Proceed to Step 2", you'll see that nothing is passed. Now, where did I go wrong? Cheers, tedd PS: I've tried this on two different servers and get the same results. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php