|
Posted by ZeldorBlat on 06/09/07 14:33
On Jun 9, 9:50 am, Mark Nenadov <m...@freelance-developer.com> wrote:
> I'm attempting to pass a SQL query to a MySQL database through PHP's
> mysql_query() function.
>
> When I do it, I get an error saying :
>
> "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 '' at
> line 1"
>
> As far as I can tell, there are no syntax errors in my query. In fact,
> when I run in through the command line mysql client, it works fine.
>
> The query is:
>
> SELECT record.name, musician.name, record.year, rating.id
> FROM musician, reviewer, record
> LEFT JOIN rating ON record.id = rating.record_id
> WHERE musician.id = record.musician_id
> AND (musician.id=19 OR musician.redirect_id=19)
> ORDER BY record.year
>
> I'm using PHP 5.2.1 and MySQL 5.0.26.
>
> Can anyone help me here? Is there any way I can get this query (or
> something that has the same effect) to work with mysql_query()? Does this
> maybe have something to do with the content in the brackets being
> considered a sub query and the PHP mysql_query not supporting sub
> queries? I'd appreciate any assistance I can get.
>
> --
> Mark Nenadovhttp://www.marknenadov.com/
Where did you get the query above? Try echo'ing out the value that
you're passing to mysql_query() to make sure it's what you think it is.
[Back to original message]
|