Error in column names of mysql table

Hello,

I am trying to get the column names of the table with the PHP code below, but the problem occurs only in one table.

Is there something wrong with the php code or is there something wrong with the table?

Note: database piwigo album script

piwigo table

DROP TABLE IF EXISTS `groups`;
CREATE TABLE IF NOT EXISTS `groups` (
  `id` smallint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '',
  `is_default` enum('true','false') NOT NULL DEFAULT 'false',
  `lastmodified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `groups_ui1` (`name`),
  KEY `lastmodified` (`lastmodified`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;
COMMIT;

Php code

$result = $db->query("SHOW COLUMNS FROM groups");
$result->fetchAll(PDO::FETCH_NUM)

Error message

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'groups' at line 1 in \test3.php on line 39

Note: there is no data in the table

Groups is a reserved keyword. To use it as a table name (identifier), you need to enclose it in back-ticks, like the usage in the DROP TABLE … and CREATE TABLE … syntax.

I didn’t fully understand
It is installed in the database
I downloaded the table with PhpMyAdmin to show you

I downloaded three empty tables next to each other with PhpMyAdmin.
What is wrong with just the groups table?

--
-- Tablo için tablo yapısı `favorites`
--

DROP TABLE IF EXISTS `favorites`;
CREATE TABLE IF NOT EXISTS `favorites` (
  `user_id` mediumint UNSIGNED NOT NULL DEFAULT '0',
  `image_id` mediumint UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`user_id`,`image_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Tablo için tablo yapısı `groups`
--

DROP TABLE IF EXISTS `groups`;
CREATE TABLE IF NOT EXISTS `groups` (
  `id` smallint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '',
  `is_default` enum('true','false') NOT NULL DEFAULT 'false',
  `lastmodified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `groups_ui1` (`name`),
  KEY `lastmodified` (`lastmodified`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Tablo için tablo yapısı `group_access`
--

DROP TABLE IF EXISTS `group_access`;
CREATE TABLE IF NOT EXISTS `group_access` (
  `group_id` smallint UNSIGNED NOT NULL DEFAULT '0',
  `cat_id` smallint UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`group_id`,`cat_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

I changed the table name from “groups” to “groupss” and got the column names.
I wonder if mysql or PhpMyAdmin conflicted with a table it uses?

Sponsor our Newsletter | Privacy Policy | Terms of Service