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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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. |