I
I
i_want_to_know_everything2016-10-11 03:18:08
PHP
i_want_to_know_everything, 2016-10-11 03:18:08

SQL query error?

To create tables in the database, the following query is generated in the database

CREATE TABLE IF NOT EXISTS `grtgh_message` (
  `id_message` mediumint(9) NOT NULL AUTO_INCREMENT,
  `time_message` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `title` varchar(128) DEFAULT NULL,
  `phone` varchar(64) NOT NULL,
  `email` varchar(64) DEFAULT NULL,
  `send_name` varchar(64) DEFAULT NULL,
  `text` varchar(600) DEFAULT NULL,
  UNIQUE KEY `id_message` (`id_message`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `grtgh_texts` (
  `id_message` mediumint(9) NOT NULL AUTO_INCREMENT,
  `time_message` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `field_name` varchar(64) NOT NULL,
  `field_text` longtext,
  UNIQUE KEY `id_message` (`id_message`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `grtgh_users` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_pass` varchar(64) NOT NULL,
  `user_login` varchar(64) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

everything works great directly in the database through PMA, but through php the script swears like this
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 'CREATE TABLE IF NOT EXISTS `grtgh_texts` (
`id_message` mediumint(9) NOT NULL '

What does he not like?
UPD: I use this to work with the database shim on PDO https://github.com/lincanbin/PHP-PDO-MySQL-Class/t...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-10-11
@i_want_to_know_everything

PDO only supports multi-queries when using the PDO_MYSQLND driver, and then some problems remain. As an option - just issue these requests one by one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question