Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySql + ASP can = weirdness

Status
Not open for further replies.

struth

Programmer
Aug 26, 2001
114
GB
I have done this sort of thing thousands of times with access:

[red]<%
if Session("memberID") = rsApplication("ID") then
response.write ("do something")
else
response.write ("do something else")
end if
%>[/red]

But it won't work. I do a check ... the values match but I get the 'else' response.

I use the same session("memberID") to build a membership recordset and then it works as it should ...

[red]if rsMember("ID") = rsApplication("ID") then[/red] ... and it all works

I check MySql - both int fields - the one generating the session and application. Change them to Integer fields - but same result.

Can anyone shed any light on this?





&quot;Away from the actual ... everything is virtual&quot;
 
Have you tried doing it like this?
Code:
[blue]<%
if [red]Trim([/red]Session("memberID")[red])[/red] = [red]Trim([/red]rsApplication("ID")[red])[/red] then
  response.write ("do something")
else
  [green]' if the [b]Trim[/b] functions above don't solve it, try inspecting the values:[/green]
  response.write " memberID = '" & [b]Trim([/b]Session("memberID")[b])[/b] & "'"
  response.write " ID = '" & [b]Trim([/b]rsApplication("ID")[b])[/b] & "'"
  response.write ("do something else")
end if
%>[/blue]
 
You could also try:

<%
if cint(Session("memberID")) = cint(rsApplication("ID")) then
response.write ("do something")
else
response.write ("do something else")
end if
%>

However, cint has problems with NULL.

rsshetty.
It's always in the details.
 
cint is required only for the session variable, the recordset will always return integer...

Known is handfull, Unknown is worldfull
 
Oops, I didn't notice those were numeric data.[blush]
Just change the Trim functions (in my example) to Cdbl (Cint function won't work if the value is greater than 32767).
 
Actually, trim probably would work because it would convert them to strings in order to satisfy the requirements of the trim funtion, so they would then both be strings (i think)

Well, or not. It sounds good though, doesn't it? :)

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Thanks. I have tried all of the above and all of them now give me the same error on the session variable:

Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: "7"]'

7 is the number I am expecting it to return on this occasion

&quot;Away from the actual ... everything is virtual&quot;
 
Ignore the last post.... my error on scripting ... messed up with the brackets!

Cdbl did the trick.

Many thanks to all.

&quot;Away from the actual ... everything is virtual&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top