Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

trungsonqlkd
Aug 24, 2006, 12:34 AM
Hi,
I am VIetnammes I am studying informatic technonogy. I am studing shopping cart, I downed this demo ones is acart2_0 , but I have problem in error.
In eacht pages that have SQL inner join that it don't run
This code example
<%@ LANGUAGE = "VBScript" %>
<!-- #include file="db.asp" -->
<!-- #include file="config.asp" -->
<!-- #include file="functions.asp" -->
<!-- #include file="wishlist.asp" -->

<%
Productid=valid_sql(request.querystring("productid"))

If productid=null or productid="" or not(isnumeric(productid)) then
response.redirect("error.asp?msg=" & Server.URLEncode("We have no record of the product you are looking for."))
End if

'get the relevant products details
Set rsprod=db.execute("SELECT * FROM products INNER JOIN categories ON products.catcode = categories.catcode WHERE products.productid = " & productid)

If rsprod.eof then
response.redirect("error.asp?msg=" & Server.URLEncode("We have no record of the product you are looking for."))
End if


If request.querystring("wish")="add" then
WISHLIST_add(productid)
End if

'get names and codes of all products in that category
Set rscatlist=db.execute("select name,productid from products where catcode=" & rsprod("catcode") & " order by name")
%>
<html>

<head>
<title>
<%= storename %>
</title>

<body bgcolor="<%= bgcolor %>" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" text="<%= text %>" alink="<%= COLlight %>" link="<%= COLlight %>" vlink="<%= vlink %>">
<font face="arial">
<%
Header

Categorymenu
%>


<table>
<td valign=top align=right>
<font face="helvetica" size="3" color="<%= COLdark %>"><B><%= rsprod("catname") %></B></font>
<br>
<%

'Display list of other products in category
if not rscatlist.eof then
rscatlist.movefirst
while not rscatlist.eof
%>
<font size="1" face="helvetica" color="<%= COLlight %>">
<a href="product.asp?productid=<%= rscatlist("productid")%>"><%=rscatlist("name")%></a>
<br>
<%
rscatlist.movenext
wend
end if
%>
</td>

<td>
<% = rsprod("image") %>
</td>

<td width=180 align="left">
<font size="3" face="helvetica" color="<%= text %>">
<b><%= rsprod("name") %></b>
<br>
<table width=180 border=0>
<tr>
<td align="left">
<font size="2" face="helvetica" color="<%= COLdark %>">
<b>Price:</b>
</td>
<td align="right">
<font size="2" face="helvetica" color="<%= text %>">
<% if rsprod("saleprice")="" or rsprod("saleprice")=0 then %>
<% =cursymbol & formatnumber(rsprod("price")) %>
<% else %>
<strike>
<% =cursymbol & formatnumber(rsprod("price")) %>
</strike>
</tr>
<tr>
</td>
<td><font size="2" face="helvetica" color="<%= COLsale %>">
Sale Price:
</td>
<td align="right">
<font size="2" face="helvetica" color="<%= COLsale %>">
<b><% =cursymbol & formatnumber(rsprod("saleprice")) %></b>
<font size="2" face="helvetica" color="<%= text %>">
<% end if %>

</td>
</tr>
</table>
<br>


<font size="1">
<%= rsprod("description") %>
<br><br>
<center>
<a href="addprod.asp?productid=<%= rsprod("productid")%>"><img src="http://www.askmehelpdesk.com/images/purchase.gif" border=0></a>
<% if not(WISHLIST_element(rsprod("productid"))) then %>
<br>
<a href="product.asp?productid=<%= rsprod("productid")%>&wish=add"><img src="http://www.askmehelpdesk.com/images/addwish.gif" border=0></a>
<% end if %>
</td>




</table>

<% footer %> </font>

</body>
</html>

<%
Db.close
Set db=nothing
%>
----------------------
While run it have error in row :

set rscatlist=db.execute("select name,productid from products where catcode=" & rsprod("catcode") & " order by name")

-------------------------
I think it don't run in : &rsprod("cacode") because SQL inner join don' runt
I think this Stament is fasle...

I thank who can help me?

trungsonqlkd
Aug 24, 2006, 12:46 AM
http://www.alanward.net/acart/acart20.asp

I downloald this shooping cart but it don't run.
I want help
I code error in SQL that have inner jion

You try down and find error help me
Thank you.

ScottGem
Aug 24, 2006, 05:50 AM


What database are you running in the back end? If you are going against an Access (Jet) database then you may need to close your SQL statements with a ; like so:

SELECT * FROM products INNER JOIN categories ON products.catcode = categories.catcode WHERE products.productid = " & productid & ";"

Also, have you tried testing your queries directly to make sure the SQL works and the right records arer returned?