Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with Session variables

Explorer ,
May 09, 2008 May 09, 2008
On page 1 I am setting a session variable based on a users log in:

<cfif NOT IsDefined("SESSION.EmpNo")>
<cfset SESSION.EmpNo = #Form.HREmpNo#>
</cfif>

On page 2, I call the session variable into a query to pre-fill a form, this works fine:

<cfquery name="qEmpInfo" datasource="SelfNom">
SELECT *
FROM tblEmployeeList
WHERE EmployeeNo = #session.EmpNo#
</cfquery>

On the same page, I give the prefilled info hidden tags so I can enter the infor into a table on the following page. qEmpInfo is the query I am hitting successfully with my session variable. Here are my tags:

<cfoutput>#qEmpInfo.EmployeeNo#</cfoutput>
<input type="hidden" name="EmployeeNo" value="#qEmpInfo.EmployeeNo#" />

On the 3rd page, where I try to insert the infor into another table, I am getting an error. Itacts like my session variable is gone.

Error:
Syntax error in date in query expression '#qEmpInfo.EmployeeNo#'.

I entered this code on page 3 to check and it by passes it I assume because it does not find the session variable:

<cfif NOT IsDefined("SESSION.EmpNo")>
<cfoutput>#session.EmployeeNo#</cfoutput>
</cfif>

I set my session time out in the admin to 24 hours, so that should not be the issue. And I have turned on session variables in the Application.cfm:

<cfapplication name="SelfNom"
sessionmanagement="Yes">



Does anyone see something I am doing wrong?
285
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 09, 2008 May 09, 2008
Jatrix wrote:
> Does anyone see something I am doing wrong?

Well the first thing I noticed is this:
<cfif NOT IsDefined("SESSION.EmpNo")>
<cfoutput>#session.EmployeeNo#</cfoutput>
</cfif>


'session.empNo' AND 'session.EmployeeNo' are not the same variable. You
check for the existence for the first and then try to output the second.
You create a variable named 'employeeNo' in your form. Is that the
one you meant to be using here? 'form.employeeNo' not 'session.employeeNo'

Translate
LEGEND ,
May 09, 2008 May 09, 2008
If EmployeeNo is a number field in the database you don't need quotes around it in the query.

So this:

'#qEmpInfo.EmployeeNo#'

Should be this in the query:

#qEmpInfo.EmployeeNo#

--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"Jatrix" <thejatrix32@yahoo.com> wrote in message news:g01mno$6fj$1@forums.macromedia.com...
> On page 1 I am setting a session variable based on a users log in:
>
> <cfif NOT IsDefined("SESSION.EmpNo")>
> <cfset SESSION.EmpNo = #Form.HREmpNo#>
> </cfif>
>
> On page 2, I call the session variable into a query to pre-fill a form, this
> works fine:
>
> <cfquery name="qEmpInfo" datasource="SelfNom">
> SELECT *
> FROM tblEmployeeList
> WHERE EmployeeNo = #session.EmpNo#
> </cfquery>
>
> On the same page, I give the prefilled info hidden tags so I can enter the
> infor into a table on the following page. qEmpInfo is the query I am hitting
> successfully with my session variable. Here are my tags:
>
> <cfoutput>#qEmpInfo.EmployeeNo#</cfoutput>
> <input type="hidden" name="EmployeeNo" value="#qEmpInfo.EmployeeNo#" />
>
> On the 3rd page, where I try to insert the infor into another table, I am
> getting an error. Itacts like my session variable is gone.
>
> Error:
> Syntax error in date in query expression '#qEmpInfo.EmployeeNo#'.
>
> I entered this code on page 3 to check and it by passes it I assume because it
> does not find the session variable:
>
> <cfif NOT IsDefined("SESSION.EmpNo")>
> <cfoutput>#session.EmployeeNo#</cfoutput>
> </cfif>
>
> I set my session time out in the admin to 24 hours, so that should not be the
> issue. And I have turned on session variables in the Application.cfm:
>
> <cfapplication name="SelfNom"
> sessionmanagement="Yes">
>
>
>
> Does anyone see something I am doing wrong?
>
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2008 May 09, 2008
LATEST
Jatrix wrote:
> Does anyone see something I am doing wrong?

Well the first thing I noticed is this:
<cfif NOT IsDefined("SESSION.EmpNo")>
<cfoutput>#session.EmployeeNo#</cfoutput>
</cfif>


'session.empNo' AND 'session.EmployeeNo' are not the same variable. You
check for the existence for the first and then try to output the second.
You create a variable named 'employeeNo' in your form. Is that the
one you meant to be using here? 'form.employeeNo' not 'session.employeeNo'

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources