Forum Moderators: coopster

Message Too Old, No Replies

You have an error in your SQL syntax; check the manual that correspond

Product export help

         

yoma

12:45 pm on Jun 18, 2010 (gmt 0)

10+ Year Member



Hi all,

Hope some can help here because I'm none too good at php and can't figure this out. I'm basically just trying to do a product export of my ecommerce store. The code in question is below;

$query = "SELECT * FROM tblTrackitProducts WHERE Visible='Y' AND (VisibleNoStock='Y' OR StockLevel > 0) GROUP BY StyleID, ProductColour"; 
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());


Which is resulting in the following error message;

Error in query: SELECT * FROM tblTrackitProducts WHERE Visible='Y' AND (VisibleNoStock='Y' OR StockLevel > 0) GROUP BY StyleID, ProductColour. 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 '|371|' at line 1


Can anyone spot any obvious mistakes?

Cheers.

rocknbil

4:29 pm on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard yoma, two things:

This is not a problem with PHP, it's a problem with mySQL. Try taking the select statment and pasting it right into PHPmyAdmin or whatever database interface you use.

Second, I don't **think** this is the exact location of your error, because

syntax to use near '|371|'


There's no possibility of such a value in your select (that I can tell.) If you had a where with that select, it would be different, but you don't.

trying to do a product export


Are there any subsequent insert statements after this? I'm speculating (and that's all it is, really) that you're pulling the records and inserting them somewhere, which would be the only place you could arrive at |371|. I see your die error agrees with the select, but a mistake I've made before . . . .

$query = "select * from table";
$result = mysql_query($query) or die("Error $query");

// blah blah

$query2 = "insert into table(fields) values('values')";
$result = mysql_query($query2) or die("Error $query");

Which would mislead you to think the problem is in query 1. By your query error,it can't be (again, I don't *think* it can) . . . been there, done that.

Try the select in phpMyAdmin, if it runs, it's something else.