Reputation: 1903
I have select code like this:
mysql_query('
SELECT id, date, ip, page, get, referer
FROM iplog ORDER BY id DESC
');
My problem is, name of column called get causes error.
When I change column name in both here and in database, error is gone. Any ideas?
Upvotes: 1
Views: 60
Reputation: 3170
put the names in backticks like
`get`
Then your query will be look like:
mysql_query('
SELECT id, date, ip, page, `get`, referer
FROM iplog ORDER BY id DESC
');
because get is a keyword/reserve word in mysql
Upvotes: 0
Reputation: 1269953
Use backquotes for reserved words (or names with characters like spaces):
SELECT id, date, ip, page, `get`, referer FROM iplog ORDER BY id DESC
get
is a reserved word in MySQL 5.7. The list is here. It starts appearing as a reserved word in MySQL 5.6.
Upvotes: 5
Reputation: 7324
One of these is probably a reserved word for your database. If you cannot detemrine which, nor want to, wrap each name in backticks like:
`date`
Upvotes: 0