0

[MOAT.GG] Query Error:

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 'rank, first_join, last_join, avatar_url, playtime, inventory_credits, event_cred' at line 1 |

With Query:

INSERT INTO player (steam_id, name, rank, first_join, last_join, avatar_url, playtime, inventory_credits, event_credits, donator_credits
) VALUES (
 ?, ?, NULL, UNIX_TIMESTAMP(), NULL, ?, 0, 0, 0, 0);
INSERT INTO player_iplog (SteamID, Address, LastSeen
) VALUES (
  ?, ?, UNIX_TIMESTAMP()
);
true

CREATE TABLE IF NOT EXISTS `player` (
    `steam_id` bigint(17) NOT NULL,
    `name` varchar(100) DEFAULT NULL,
    `rank` varchar(60) DEFAULT NULL,
    `first_join` int(10) DEFAULT NULL,
    `last_join` int(10) DEFAULT NULL,
    `avatar_url` varchar(150) DEFAULT NULL,
    `playtime` int(10) DEFAULT NULL,
    `inventory_credits` int(10) unsigned DEFAULT NULL,
    `event_credits` int(10) unsigned DEFAULT NULL,
    `donator_credits` int(10) unsigned DEFAULT NULL,
    `extra` varchar(150) DEFAULT NULL,
    `rank_expire` int(11) DEFAULT NULL,
    `rank_expire_to` varchar(32) DEFAULT NULL,
    `rank_changed` int(11) DEFAULT NULL,
    `mvp_access` int(11) DEFAULT NULL,
    PRIMARY KEY (`steam_id`),
    KEY `rank` (`rank`),
    KEY `inventory_credits` (`inventory_credits`),
    KEY `playtime` (`playtime`),
    KEY `last_join` (`last_join`),
    FULLTEXT KEY `name` (`name`)
);
Akhilesh Mishra
  • 5,876
  • 3
  • 16
  • 32
  • 2
    Do you really try to insert first and then to create a table? – Sergey Jan 15 '21 at 08:03
  • 1
    `rank` is a [reserved word](https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-R) and has to be wrapped in backticks when using it in a query – Cid Jan 15 '21 at 08:06
  • 2
    `rank` became a reserved word in MySQL 8.0. – Barmar Jan 15 '21 at 08:08
  • 2
    @TimBiegeleisen That wouldn't cause a syntax error. It's almost certainly the reserved word problem. – Barmar Jan 15 '21 at 08:08
  • 2
    @Barmar Well, yes it would first cause a syntax error : [fiddle](https://www.db-fiddle.com/f/7qKakgoT1mSrshV9oD3Drj/0) Once fixed, this will lead to the non existing table error – Cid Jan 15 '21 at 08:11
  • how exactly do i fix the issues? Like what exactly do i change? – Thomas Drewel Jan 15 '21 at 17:05

0 Answers0