Помогите люди добрые **Запрос:** CREATE TABLE IF NOT EXISTS `groups` ( `group_id` int(11) NOT NULL AUTO_INCREMENT, `group_name` text NOT NULL, `group_info` text NOT NULL, `owner_login` varchar(16) NOT NULL, UNIQUE KEY `group_id` (`group_id`) ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1; Когда я отправляю запрос через phpmyadmin то таблица создается, а если пытаюсь отправить запрос через mysql_query() то таблица не создается. В чем ошибка?
- Show the PHP code, there the FIG knows what's going on. Maybe you just write a request like this, without quotes. We do not know ... Although the feeling that I did not read this . Namely " The query string should not end with a semicolon " - BOPOH
|
1 answer
Well, I think it should be like this:
mysql_query("CREATE TABLE ИмяТаблицы(ИмяПоля тип,ИмяПоля тип)") or die(mysql_error());
and more detailed option:
db_connect($serverMySql,$db_log,$db_pass); mysql_select_db($database); mysql_query("CREATE TABLE users(id int auto_increment primary key, email TINYTEXT, password VARCHAR(16), name TINYTEXT, daybirth VARCHAR(2), monthbirth VARCHAR(40), yearbirth VARCHAR (4))") or die(mysql_error()); mysql_close(); print "Таблица создана!<br>";
Well, if it does not, then: Here!
- Sorry for not formatting the code. - MrGons18
- formatted, there you select the code and click on the braces :) - thunder
- And how, in this case, specify the type of the table and FK, for example? Well, MyIASM can by default be created, and if innoDB or NDB? - BOPOH
- Sorry, I'm not great in SQl requests, I am more on php and unpretentious requests)). - MrGons18
|