472,353 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Session Variable - array problem

Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL

Jul 22 '05 #1
3 2885
"Neil Jarman" wrote ...
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.


Hi Neil,

Not saying you're wrong - as I've not used Session.Contents before - but I
didn't see an example of its use the way you've tried to use it here:

http://www.w3schools.com/asp/asp_sessions.asp

(not suggesting this is the entire scope of this listed here mind!)..

I was able to get your example to work though when I changed it to read:

<%

for each key in request.QueryString

if left(key,6) = "cboRun" then

iIndex = cint(mid (key,7))

session.Contents("iRunNo") = iIndex ' this is the line I
changed

end if

next

Response.Write "And finally: " & Session("iRunNo")

%>

I'm sure you probably have anyway in your application - but obviously this
example doesn't have any kind of error catching around cboRun if the
querystring doesn't come back with what you expect...ie, if I changed it to
: cboRunMONKEY17 - suddenly there are errors where trying to cInt
stuff....just thought it worth mentioning...

Regards

Rob

Jul 22 '05 #2
To save an array in a session variable you have to create the array as a
local variable first then put it into a session variable. To access it later
you have to put it into a local variable again.

(note: from memory, may need some adjustments)

dim aIn(), aOut
dim i, key, iIndex

redim aIn( request.querystring.count ) 'make array big enough to hold all
params

i = 0
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
aIn(i) = iIndex ' could use aIn(iIndex)=iIndex if that is what is
needed
i = i + 1
end if
next
redim preserve aIn( i-1 ) 'adjust upper bound to match count of desired
params
Session("iRunNo") = aIn

aOut = Session("iRunNo")
for i = 0 to ubound(aOut)
response.Write(aOut(i) & "<br>")
Next

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Neil Jarman" <ne**@tNOiSPAMvPLEASEy.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a
single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL

Jul 22 '05 #3
Hi Mark,

Thanks for the help, I will test it tomorrow - typical that my book glossed
over that part!

Cheers,

NEIL
"Mark Schupp" <no******@email.net> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
To save an array in a session variable you have to create the array as a
local variable first then put it into a session variable. To access it later you have to put it into a local variable again.

(note: from memory, may need some adjustments)

dim aIn(), aOut
dim i, key, iIndex

redim aIn( request.querystring.count ) 'make array big enough to hold all
params

i = 0
for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
aIn(i) = iIndex ' could use aIn(iIndex)=iIndex if that is what is
needed
i = i + 1
end if
next
redim preserve aIn( i-1 ) 'adjust upper bound to match count of desired
params
Session("iRunNo") = aIn

aOut = Session("iRunNo")
for i = 0 to ubound(aOut)
response.Write(aOut(i) & "<br>")
Next

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Neil Jarman" <ne**@tNOiSPAMvPLEASEy.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I need to create an array with a session variable.

According to thebook I'm using, the following should work, but if fails:

for each key in request.QueryString
if left(key,6) = "cboRun" then
iIndex = cint(mid (key,7))
response.Write(iIndex & "<br>")
session.Contents("iRunNo")(iIndex)=iIndex
end if
next

it is the (iIndex) part which fails. If I remove this, then I can create a single session variable

Any suggestions where I'm going wrong.

Many thansk

NEIL


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
1
by: Sean Pinto | last post by:
Ok, you all are going to have to bear with me on this one as it is kinda complicated to explain. I am implementing a company management suite that...
1
by: s_m_b | last post by:
I am having a problem with a page that creates a treeview from a database, by reloading itself on each request for a new folder to be explored. The...
7
by: Nicole | last post by:
Hi I'm trying to use a function to set a session variable. I have three files: The first file has: <?php session_start(); // This connects...
9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object...
4
by: tma | last post by:
I'm trying to save code to a session object like the following: dim oAppList as arraylist dim oApp as someclass Code to manipulate oApp......
3
by: Brad | last post by:
I am storing an array which contains about a dozen chracter items to a Session variable. Later, I need to use this array so I am doing the...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to...
6
by: Vyoma | last post by:
This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I have been lurking around at several forums with...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.