Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Broken MySQL table

Can insert into one table in db but no another

5:03 pm on Jan 20, 2010 (gmt 0)

New User

5+ Year Member

joined:Jan 14, 2010
posts: 7
votes: 0

Evening all, a little stumped.

I have a simple MySQL query as below that I am re-using from another page with different values:

$qry = "INSERT INTO match(matchdate,matchtime,opposition) VALUES('$matchdate','$matchtime','$opposition')";
$result = @mysql_query($qry);

However this returns the error message:

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 'match(matchdate,matchtime,opposition) VALUES('19/01/2009','19:00','Stoke')' at line 1

There are only 2 tables in the DB at present, if I change the table name and fields to the other one then it works fine.

Have checked all the connection settings / fieldnames and everything else I can think of, is it possible that a table could just simply not work?

7:56 pm on Jan 20, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Match [dev.mysql.com] is a mysql function. You should avoid these types of names for two reasons, the first being the obvious conflict, the second, because the table names would be extremely easy to guess.

But a fix, should you choose to go with it, is to backtick the table name. This should do it.

$qry = "INSERT INTO `match` (matchdate,matchtime,opposition) VALUES('$matchdate','$matchtime','$opposition')";

9:26 am on Jan 21, 2010 (gmt 0)

New User

5+ Year Member

joined:Jan 14, 2010
posts: 7
votes: 0

Ahhhh.... foiled by my limited MySQL vocabulary!

Thanks for that, would have been tearing my hair out for a long time attempting to google it.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members