473,226 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Session variable

I'm going nuts over this one. Perhaps this is kludgy, but it has worked for
me before.

When I give the user a form, say AAA.php that has a few fields on it, and he
has to fill it out, I check for validity. If I find an error, I created a
session variable like:

$_SESSION['AnError'] = "Description of the error";

I then call the form again with

header("Location: ThisForm.php");

In the <body> area I have

<?php if (isset($_SESSION['AnError'])) echo $_SESSION['AnError']; ?>

Doing thing like this has worked before. Now, for a particular form when I
try it, it doesn't display. I tested it further with

<?php echo "Error: . $_SESSION['AnError']; ?>

and only the "Error: " displayed. This told me that the session variable
was not set. However, if I put echos in the code immediately after it gets
set, then it echos and prints further that the headers have already been set
(BTW, what does that mean?). So, I know that it is being set, it is not
being unset anywhere, yet it isn't set when the form redisplays.

I have been banging my head against the wall for hours now. Anyone have any
ideas?

Shelly
Jul 17 '05 #1
2 1267

"Shelly" <sh************@asap-consult.com> wrote in message
news:MM********************@comcast.com...
I'm going nuts over this one. Perhaps this is kludgy, but it has worked
for me before.

When I give the user a form, say AAA.php that has a few fields on it, and
he has to fill it out, I check for validity. If I find an error, I
created a session variable like:

$_SESSION['AnError'] = "Description of the error";

I then call the form again with

header("Location: ThisForm.php");

In the <body> area I have

<?php if (isset($_SESSION['AnError'])) echo $_SESSION['AnError']; ?>

Doing thing like this has worked before. Now, for a particular form when
I try it, it doesn't display. I tested it further with

<?php echo "Error: . $_SESSION['AnError']; ?>

and only the "Error: " displayed. This told me that the session variable
was not set. However, if I put echos in the code immediately after it
gets set, then it echos and prints further that the headers have already
been set (BTW, what does that mean?). So, I know that it is being set, it
is not being unset anywhere, yet it isn't set when the form redisplays.

I have been banging my head against the wall for hours now. Anyone have
any ideas?

Shelly


Well, it works now. I am not sure why, but here is what I did. After I had
echoed the variable in the <body> area, I had unset it since I didn't want
to keep it around after the display. What I changed was that I removed
that unset and placed it where I successfully started to upload the file
that I wanted. In other words, where there were no client side errors.

Could someone explain to me why that works? Is it that it does the page
twice on redisplay, getting the variable on the first time but then it
doesn't have it on the second pass (after the original unset)?

Shelly
Jul 17 '05 #2
On Sat, 09 Jul 2005 15:52:52 -0400, Shelly wrote:
and only the "Error: " displayed. This told me that the session variable
was not set. However, if I put echos in the code immediately after it gets
set, then it echos and prints further that the headers have already been set
(BTW, what does that mean?). So, I know that it is being set, it is not
being unset anywhere, yet it isn't set when the form redisplays.

I have been banging my head against the wall for hours now. Anyone have any
ideas?


Yes. Probably, your web server has specified the nature of the error in
the log file. My server (Apache 2.0.53) does it like this:
[client 127.0.0.1] PHP Parse error: parse error, unexpected '{' in
/home/mgogala/work/DBA/security.php on line 25, referer:
http://localhost/dba/main_menu.html

If I am not mistaken, you haven't started the session, in the first place.
This is how things should look:

<?php
require_once ('config.php');
session_start();
$DSN = $_SESSION['DSN'];
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$ADODB_COUNTRECS = true; $db = NewADOConnection("oci8");
$usr = $_GET['user'];
$USRINFO = 'select USERNAME,
ACCOUNT_STATUS STATUS,
EXPIRY_DATE EXPIRES,
DEFAULT_TABLESPACE "DFLT. TBLSPCE",
TEMPORARY_TABLESPACE "TEMP. TBLSPCE",
CREATED,PROFILE,
........

After invoking the session_start() function, I can read my connect
information into the $DSN variable. Last, saying that "this has
worked before" makes no sense whatsoever and is probably the single
most irritating thing you can say to a support person. You either have
to explain before what exact event was it working or get the support
person to start believing in ghosts which are haunting your code. If
the support person has geeky sense of humor, it can be rather unpleasant
proposition.

--
http://www.mgogala.com

Jul 17 '05 #3

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

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
2
by: Eric | last post by:
Hi, I've a problem with trying to retrieve a session variable in an include file. Basically, the main asp creates a session variable: <% Session("var1") = "Hello" %> And then when I click...
4
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
17
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.