[SOLVED] Query problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

[SOLVED] Query problems

Post by dwfait »

I get this error:

Code: Select all

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 'read=0' at line 1
On this query:

Code: Select all

$query = mysql_query("SELECT * FROM pm WHERE toid='$suser' AND read=0") or die(mysql_error());
ANy help to resovle this matter would be appreciated.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

What does your table look like?
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

It has 7 fields, in this order:

id(primary) toid fromid date subject message read (default 0)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

READ is a mysql reserved word. Either rename the column or backquote it, `read`

http://dev.mysql.com/doc/mysql/en/Reserved_words.html
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

bah. again lol. Thanks mark.
Post Reply