Bluehost.com Web Hosting $6.95

Shopping Cart Woes

This is a discussion on Shopping Cart Woes within the PHP General forums, part of the PHP Programming Forums category; I am developing a shopping cart for a college project but I have come unstuck when I try to view ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-03-2004
Boab C
 
Posts: n/a
Default Shopping Cart Woes

I am developing a shopping cart for a college project but I have come
unstuck when I try to view my cart. The error that I am encountering
is as follows:

"You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'IN (64) ORDER BY dvd.dvd_title ASC' at line 1".

The error appears to be from this part of my script:

$query = 'SELECT * FROM dvd IN (';
foreach ($_SESSION['cart'] as $key => $value) {
$query .= $key . ',';
}
$query = substr ($query, 0, -1) . ') ORDER BY dvd.dvd_title ASC';
$result = mysql_query ($query) or die(mysql_error());


Could someone please tell me what is wrong with this query.
Reply With Quote
  #2 (permalink)  
Old 01-04-2004
Nick
 
Posts: n/a
Default Re: Shopping Cart Woes

Try to print your query before sending it to MySQL.You 'll find the
error much easier that way :)
Boab C wrote:
> I am developing a shopping cart for a college project but I have come
> unstuck when I try to view my cart. The error that I am encountering
> is as follows:
>
> "You have an error in your SQL syntax. Check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near 'IN (64) ORDER BY dvd.dvd_title ASC' at line 1".
>
> The error appears to be from this part of my script:
>
> $query = 'SELECT * FROM dvd IN (';
> foreach ($_SESSION['cart'] as $key => $value) {
> $query .= $key . ',';
> }
> $query = substr ($query, 0, -1) . ') ORDER BY dvd.dvd_title ASC';
> $result = mysql_query ($query) or die(mysql_error());
>
>
> Could someone please tell me what is wrong with this query.

Reply With Quote
  #3 (permalink)  
Old 01-04-2004
Boab C
 
Posts: n/a
Default Re: Shopping Cart Woes

Thanx for the tip Nick. I have now managed to resolve the problem. It
turned out to be something very simple, how annoying!!! The query was
missing a "WHERE" clause, I amended to query to:

$query = 'SELECT * FROM dvd WHERE dvd_id IN (';.....

That resolved the problem. Thanx again.


Nick <vorian@pat.forthnet.gr> wrote in message news:<1073213099.651982@athnrd02.forthnet.gr>...
> Try to print your query before sending it to MySQL.You 'll find the
> error much easier that way :)
> Boab C wrote:
> > I am developing a shopping cart for a college project but I have come
> > unstuck when I try to view my cart. The error that I am encountering
> > is as follows:
> >
> > "You have an error in your SQL syntax. Check the manual that
> > corresponds to your MySQL server version for the right syntax to use
> > near 'IN (64) ORDER BY dvd.dvd_title ASC' at line 1".
> >
> > The error appears to be from this part of my script:
> >
> > $query = 'SELECT * FROM dvd IN (';
> > foreach ($_SESSION['cart'] as $key => $value) {
> > $query .= $key . ',';
> > }
> > $query = substr ($query, 0, -1) . ') ORDER BY dvd.dvd_title ASC';
> > $result = mysql_query ($query) or die(mysql_error());
> >
> >
> > Could someone please tell me what is wrong with this query.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0