我试图使用PHP创建多个MySQL表,但它给出了错误,我无法理清它有什么问题.
PHP代码:
$sql = ' CREATE TABLE IF NOT EXISTS `mod_reminder_entries`
(
`id` INT(10) NOT NULL auto_increment,
`user_id` INT(10) NOT NULL,
`entry_name` VARCHAR(255) NOT NULL,
`entry_value` INT(10) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES tblclients (`id`)
);
CREATE TABLE IF NOT EXISTS `second_table`
(
`user_id` INT(10) NOT NULL,
`fieldstotal` INT(10) NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES tblclients (`id`)
); ';
mysql_query($sql);
它给出了错误,除了不用担心mysql连接.我正确地连接数据库,我测试了它,语法肯定有些不对劲.
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 second_table ( user_id INT