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)

5+ Year Member

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)

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

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)

5+ Year Member

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.


Featured Threads

Hot Threads This Week

Hot Threads This Month