473,507 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION array

1 New Member
Hi, I'm trying to create a session array and give a dynamic name.

I tried something like this but I get only the last entry i made (key=0) :
Expand|Select|Wrap|Line Numbers
  1.     $qid = $_POST['pstq'];
  2.         $_SESSION[$qid] = array();
  3.  
  4.     foreach ($_SESSION[$qid] as $key=>$value) {
  5.     echo "<table><tr><td> $key : </td><td>$value</td></tr>
  6.     }
  7.  
and i get this notice
Expand|Select|Wrap|Line Numbers
  1. Notice: Unknown: Skipping numeric key 0. in Unknown on line 0
  2.  
of course I start the session etc.
Thnx.
Oct 1 '07 #1
4 9194
djpaul
137 New Member
Hi, I'm trying to create a session array and give a dynamic name.

I tried something like this but I get only the last entry i made (key=0) :
Expand|Select|Wrap|Line Numbers
  1.     $qid = $_POST['pstq'];
  2.         $_SESSION[$qid] = array();
  3.  
  4.     foreach ($_SESSION[$qid] as $key=>$value) {
  5.     echo "<table><tr><td> $key : </td><td>$value</td></tr>
  6.     }
  7.  
and i get this notice
Expand|Select|Wrap|Line Numbers
  1. Notice: Unknown: Skipping numeric key 0. in Unknown on line 0
  2.  
of course I start the session etc.
Thnx.
But then different:
[PHP]
$qid = $_POST['pstq'];

$_SESSION['qid'] = $qid
[/PHP]

Because the super global is already some kind of array.
I used it to for my site and added some vaibles as email, status and so on.
Good luck!

Paul
Oct 1 '07 #2
Atli
5,058 Recognized Expert Expert
Hi, I'm trying to create a session array and give a dynamic name.

I tried something like this but I get only the last entry i made (key=0) :
Expand|Select|Wrap|Line Numbers
  1.     $qid = $_POST['pstq'];
  2.         $_SESSION[$qid] = array();
  3.  
  4.     foreach ($_SESSION[$qid] as $key=>$value) {
  5.     echo "<table><tr><td> $key : </td><td>$value</td></tr>
  6.     }
  7.  
and i get this notice
Expand|Select|Wrap|Line Numbers
  1. Notice: Unknown: Skipping numeric key 0. in Unknown on line 0
  2.  
of course I start the session etc.
Thnx.
Hi. Welcome to The Scripts!

The obvious error there is the missing quote-mark and semi-colon at the end of the echo statement. But, assuming that is a typo I would point out that your new $_SESSION[$qid] array is initialized each time you run the scripts as an empty array, which would presumably cause the foreach loop to be skipped entirely.

I can see no reason for the notice, however.

I did try something similar myself, which executed without warnings and gave me the results I expected:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     session_start();
  3.  
  4.     $qid = "pstg";
  5.     $_SESSION[$qid] = array("one" => 1, 2 => "Two");
  6.  
  7.     echo "<pre>";
  8.     print_r($_SESSION);
  9.     echo "</pre>";
  10. ?>
  11.  
Oct 2 '07 #3
Hemo
1 New Member
Hi, problem is bad key value of Session.
This code causes Notice
Expand|Select|Wrap|Line Numbers
  1. session_start(); 
  2. $_SESSION["1"] = array('hodnota1');
  3.  
This does not cause Notice

Expand|Select|Wrap|Line Numbers
  1. session_start(); 
  2. $_SESSION["1a"] = array('hodnota1');
  3.  
Oct 2 '12 #4
lyodmichael
75 New Member
are you trying to register a session, in a value of a textbox?
Oct 2 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
16251
by: Håvard Olerud Eriksen | last post by:
I've been working on a webshop, and I've got most of the functionality up and running. One problem, however, that I don't seem to be able to solve is as follows. My shopping cart is stored in...
5
10874
by: Rob Tweed | last post by:
Probably a simple question but I can't find the answer anyway. Specifically, is it possible to copy a multidimensional array into the $_SESSION array - ie a deep clone of all keys and data? I...
0
2467
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its...
4
3088
by: Tom | last post by:
A small problem that has me kinda baffled. This is the situation: I've set up a self-submitting form FORM.PHP. Once the inputs are validated, the info gets put in SESSION variables and the...
5
1846
by: h | last post by:
I am at my wits end; I can not see A SINGLE THING I'm doing wrong. I've read every fricking session related doc. I've searched every fricking group. NO ONE seems to have had the problem I'm having...
2
1899
by: Tom | last post by:
I put together a code that checks for 2 post variables then stores them in a multi-dim $_SESSION array, something like this: If ( isset($_POST && isset($_POST) ) { $_SESSION = $_POST;...
12
41119
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if...
2
1809
by: somecrazyguy | last post by:
Take the following code, one would think that there was absolutely no link between $test and $_SESSION. But if you reload the page, guess what... "After=FAILED". Why? Because for some reason,...
2
2019
by: gm04030276 | last post by:
hey, i'm basically trying to use php sessions and a bit of javascript to make tabbed browsing within a web page using sessions to store the data of the different opened pages. Problem: when i unset...
2
2256
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.