gpt4 book ai didi

php - 简单 : creating tables in database

转载 作者:行者123 更新时间:2023-12-01 00:28:23 24 4
gpt4 key购买 nike

非常简单的问题。我忘记了如何处理这个特定的脚本。我使用 PHP 文件在 mysql 数据库中创建表。我有带有以下命令的 $query 变量:

$query = "CREATE TABLE IF NOT EXISTS `table1` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`status` int(11) NOT NULL
)ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `table2` (
`something` varchar(100) NOT NULL,
`whatever` text NOT NULL
)ENGINE=MyISAM DEFAULT CHARSET=utf8;
";

只有当我执行一个命令时它才有效。当我运行多个 CREATE/INSERT/DROP ... 命令时,它不起作用。肯定有语法错误,可能是 ;,

最佳答案

mysql_query() 不支持在同一调用中使用多个语句。

http://php.net/manual/en/function.mysql-query.php

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

关于php - 简单 : creating tables in database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9856383/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com