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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shopping cart syntax error

Status
Not open for further replies.

pulpgirl

Technical User
Aug 10, 2007
4
US
getting a bizzare error on this page:

happens when there is nothing added to the cart. BUT if you add something to the cart and then remove it.. it shows you the cart as empty without a problem.

i get a syntax error which then refers to this line:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set rsAddItem = Server.CreateObject("ADODB.Recordset")
Conn.ConnectionTimeout = 0
Conn.Open "dsn=paceprintscatalog;uid=paceprints;pwd=pace212prints;"
rsAddItem.Open "Select b.*, a.artistID AS artistID, a.firstname AS firstname, a.lastname AS lastname FROM paceprints.basket AS b, paceprints.stocklist AS s, paceprints.artists AS a WHERE b.printID = s.UID AND s.artistID=a.artistID AND b.basketID =" & Session("basketID"), Conn, 1, 3
%>


any ideas?
 
You're getting this error because Session("basketID") is blank.

Your resulting query looks like...

[tt][blue]WHERE b.printID = s.UID AND s.artistID=a.artistID AND b.basketID =[/blue][/tt]



-George

"the screen with the little boxes in the window." - Moron
 
alright.. sorry,

i'm not surehow t go about fixing this..
tries adding this:

<%
if "basketID" = isNull Then
response.write("0")
end if
%>

but i'm going about this wrong...
any help or links to somewhere i can read up on how to fix this..would be great..

thanks!
 
Fixing the problem is easy. Knowing what the right thing to do is not. It depends on your application.

What do you want to have happen when the basketId is blank? Do you want to NOT return any records?

You could bypass the query entirely.

Code:
If Session("BasketId") <> "" Then
  ' All your existing code here.
End If

You could also rely on an implicit data type conversion in your query. This method relies on the fact that an empty string will be converted to the value 0 when compared with an integer column. So you could change this...

AND b.basketID =" & Session("basketID")

To:

Code:
AND b.basketID =[!]'[/!]" & Session("basketID") [!]& "'" [/!]

By putting apostrophes around your data, the resulting query would look like...

[tt][blue]WHERE b.printID = s.UID AND s.artistID=a.artistID AND b.basketID = ''[/blue][/tt]

This will not return any records, but it also will not fail.

I hope this helps.

-George

"the screen with the little boxes in the window." - Moron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top