Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing Operator Error

0 views
Skip to first unread message

gerberbrother

unread,
Dec 24, 2003, 11:29:05 AM12/24/03
to
Hi,

I am trying to incorporate a shopping cart in my website. So far I am working with 4 pages that are used for the shooping functionality:

catalog.cfm
productdetail.cfm
addtocart.cfm
checkout.cfm

Here is the code for the Catalog.cfm:

<html>

<title>
</title>


<head>
</head>


<cfquery name = "FindProductsQuery" datasource = "first_products">
SELECT *
FROM tbl_products
</cfquery>

<form action = "productdetail.cfm" method = "post">


<select name = "product">
class = "input"
<cfoutput query = "FindProductsQuery">
<option value = "#productid#"> #product_name# </option>
</cfoutput>
</select>


<input type = "submit" value = "view" action = "submit">

</form>


Here is the code for the productdetail.cfm:


<html>

<title>
</title>

<head>
</head>

<cfparam name = "FORM.product" type = "numeric" default = "0">

<body>

<!---
<cfinclude template = "catalog.cfm">
--->

<cfoutput>
<cfif isdefined("FORM.checkout")>
<cflocation url = "checkout.cfm">
</cfif>


</cfoutput>


<cfoutput>
tester:
#FORM.product#
</cfoutput>

<br>

<cfquery name = "FindProductDetailsQuery" datasource = "first_products">
SELECT *
FROM tbl_products
WHERE productid = #FORM.product#
</cfquery>

<cfform action = "addtocart.cfm?productid=#FORM.product#" method = "post">

<cfoutput query = "FindProductDetailsQuery">
<font face = "copperplate gothic light" size = "1">
Product ID:
#productid#
<br>
Product Name:
#product_name#
<br>
Product Description:
#product_description#
</font>


</cfoutput>

<br>


<hr size = "1">

<font face = "copperplate gothic light" size = "1">
Quantity:
</font>
<input type = "text"
name = "quantity"
size = "1">

<input type = "submit"
value = "add">


<cflock scope = "session" type = "readonly" timeout = "5">

<cfif ArrayLen(SESSION.arrQuantities)>

<input type = "submit"
value = "checkout counter"
name = "checkout">

</cfif>

</cflock>
</cfform>


</body>


Here is the code for the addtocart page:

<html>
<cfparam name = "form.product" type = "numeric" default = "0">


<body>


<!---
<cfoutput>
tester: #url.productid#
</cfoutput>
--->


<br>


<cfif isdefined("FORM.catalog")>
<cflocation url = "catalog.cfm">
</cfif>

<cfif isdefined("FORM.checkout")>
<cflocation url = "checkout.cfm">
</cfif>


<cflock scope = "session" type = "readonly" timeout = "5">


<cfif ArrayLen(SESSION.arrProducts)>
<cfset productposition = ListFind(ArrayToList(SESSION.arrProducts), FORM.product)>
<cfelse>
<cfset productposition = 0>
</cfif>


</cflock>

<cfif productposition gt 0>
<cflock scope = "session" type = "exclusive" timeout = "5">
<cfset session.arrQuantities[productposition] = session.arrquantities[productposition] + FORM.quantity>
</cflock>

<cfelse>
<cflock scope = "session" type = "exclusive" timeout = "5">
<cfset temp = ArrayAppend(SESSION.arrProducts, FORM.product)>
<cfset temp = ArrayAppend(SESSION.arrQuantities, FORM.quantity)>
</cflock>


</cfif>



<cfquery datasource = "#dsn#" name = "qGetProductInfo">
SELECT productid, product_name
FROM tbl_products
WHERE productid = #url.productid#
</cfquery>

<!---
<cfquery datasource = "#dsn#" name = "qGetProductInfo">
SELECT productid, product_name
FROM tbl_products
WHERE product_name = '#url.product_name#'
</cfquery>
--->


<cfoutput query = "qGetProductInfo">
<font face = "copperplate gorthic light" soize = "1">
added #FORM.quantity# of #product_name# to the cart
</font>
</cfoutput>


<form action = "productdetail.cfm" method = "post">

<select name = "product"
size = "1">
<cfoutput query = "qGetProductInfo">
<option value = "#ProductID#">
#product_name#
</cfoutput>

</select>

<input type = "submit"
value = "continue shopping"
name = "catalog">

<input type = "submit"
value = "view piece"
name = "detail">

<input type = "submit"
value = "checkout counter"
name = "checkout">


</form>

And here is the code for the checkout.cfm page:

<cfif isdefined("FORM.continue")>

<cflocation url = "customerinfo.cfm">

<cfif isdefined("FORM.update")>

<cfset DeleteList = "">
<cflock scope = "session" type = "exclusive" timeout = "5">
<cfloop from = "1" to = "#ArrayLen(SESSION.arrProducts)#" index = "i">

<cfif Evaluate("FORM.qty" & i) eq 0>
<cfset DeleteList = ListAppend(DeleteList, i)>

<cfelseif Evaluate("FORM.qty" & i) neq SESSION.arrQuantities>
<cfset SESSION.arrQuantities = Evaluate("FORM.qty" & i)>
</cfif>
</cfloop>


<cfif ListLen(DeleteList)>

<cfloop list = "#DeleteList#" index = "i">

<cfset temp = ArrayDeleteAt(SESSION.arrProducts, i)>
<cfset temp = ArrayDeleteAt(SESSION.arrQuantities, i)>


</cfloop>
</cfif>
</cflock>
</cfif>
</cfif>

<cfset total = 0>

<body>

Step 1: Finalize Your Cart. To update your cart... To remove items from your cart, ...


<cfform action = "checkout.cfm" method = "post">

<table>

<th>
Product ID
</th>

<tgh>
Prduct Name
</th>

<th>
Quantity
</th>

<th>
Prce
</th>

<th>
Extended Price
</th>

<cflock scope = "session" type = "readonly" timeout = "5">

<cfloop from = "1" to = "#ArrayLen(SESSION.arrproducts)#" index = "i">

<cfquery datasource = "#dsn#" name = "qGetProductInfo">


SELECT product_name, product_price, productid
FROM tbl_products
WHERE productid = #SESSION.arrproducts#
</cfquery>

<cfoutput>

<tr>
<td>
#SESSION.arrproducts#
</td>
<td>
#qGetProductInfo.Product_name#
</td>

<td>
<cfinput type = "text" name = "qty#i#" size = "3"
value = "#SESSION.arrQuantities#" required = "yes"
validate = "integer" message = "Please enter a valid quantity for Product ID #SESSION.arrProducts#">
</td>

<td>
#DollarFormat(qGetProductInfo.product_price)#
</td>

<td>
#DollarFormat(SESSION.arrQUantities * qGetProductInfo.product_price)#
</td>

</tr>

</cfoutput>

<cfset total = total + SESSION.arrQUantities * qGetProductInfo.product_price>
</cfloop>


<cfset SESSION.total = total>

</cflock>

<tr>
<td colspan = "4"> Grang Total:
</td>

<td>
<cfoutput>
#DollarFormat(total)#
</cfoutput>
</td>

</tr>

</table>

<br>
<br>

<input type = "submit" value = "update cart" name = "update">
<input type = "submit" value = "continue checkout" name = "continue">

</cfform>


</body>


</html>

For some reason when I click the "checkout" button in the productdetail page, I get an error message which says the following:


Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'productid ='.

The Error Occurred in E:\sites\gbell\test\TD\Web\checkout.cfm: line 79

77 : FROM tbl_products
78 : WHERE productid = #SESSION.arrproducts#
79 : </cfquery>
80 :
81 :


Does anyone know why?

Please take a llok at the code in my pages and suggest better ways and/or solutions.

Thanks in advance,
gerberbrother


philh

unread,
Dec 24, 2003, 12:18:40 PM12/24/03
to
The simple answer is that SESSION.arrproduct is not populated; that's why it's blank.

Secondly, it's an array, and shouldn't be used in an equality in your query. You'd have to do something like

where productID IN(#arraytolist(session.arrproducts)#)

HTH,

Phil Hegedusich
Senior Web Developer
http://www.iimak.com
The best thermal transfer printer ribbons on the planet
-----------------
How many forum members does it take to change a light bulb?

gerberbrother

unread,
Dec 24, 2003, 1:28:52 PM12/24/03
to
Hi,

I did not think of that. Well, I tried as you suggested. Now I am getting hte following error:

[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'product_name IN(,,,,,,,,,0)'.

Why?

Thanks in advance,
gerberbrother



philh

unread,
Dec 24, 2003, 2:32:39 PM12/24/03
to
Well, you have blank elements in the IN list. They should all be the same data type (blank is not an integer). Apparently your array has eight blank productIDs, and one of 0.
0 new messages