2012-04-15 195 views
0

錯誤時要創建表#1064錯誤信息

MySQL表示:

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 
'mysql_query("CREATE TABLE " . DB_TABLE_PREFIX . "mssgs (
id mediumint(5) unsig' at line 1 

mysql_query("CREATE TABLE " . DB_TABLE_PREFIX . "mssgs (
     id mediumint(5) unsigned NOT NULL auto_increment, 
     uid tinyint(3) unsigned NOT NULL default '0', 

     m tinyint(2) NOT NULL default '0', 
     d tinyint(2) NOT NULL default '0', 
     y smallint(4) NOT NULL default '0', 
     start_time time NOT NULL default '00:00:00', 
     end_time time NOT NULL default '00:00:00', 
     title varchar(50) NOT NULL default '', 
     text text NOT NULL, 
     PRIMARY KEY (id) 
    ) TYPE=MyISAM") or die(mysql_error()); 

    mysql_query("create index m on " . DB_TABLE_PREFIX . "mssgs (m)"); 
    mysql_query("create index y on " . DB_TABLE_PREFIX . "mssgs (y)"); 

    mysql_query("CREATE TABLE " . DB_TABLE_PREFIX . "users (
     uid smallint(6) NOT NULL auto_increment, 
     username char(15) NOT NULL default '', 
     password char(32) NOT NULL default '', 
     fname char(20) NOT NULL default '', 
     lname char(30) NOT NULL default '0', 
     userlevel tinyint(2) NOT NULL default '0', 
     email char(40) default NULL, 
     PRIMARY KEY (uid) 
    ) TYPE=MyISAM") or die(mysql_error()); 

    mysql_query("INSERT INTO " . DB_TABLE_PREFIX . "users 
     (username, password, fname, lname, userlevel, email) VALUES (
     'admin', 'password', 'default', 'user', 2, ''); 
    ") 
+0

您是否嘗試單獨在MySQL(phpmyadmin)上執行所有這些SQL命令? – Lion 2012-04-15 17:15:09

+0

@Lion:一定是因爲錯誤說語法錯誤附近'的mysql_query('這是不是SQL的一部分 – 2012-04-15 17:17:44

回答

1

貌似你試圖在phpadmin執行上面的代碼。

但這不是純粹的SQL。這也是PHP代碼,不會在PHPAdmin中運行。

您需要執行"之間的代碼並用值填充窗口。像那樣

CREATE TABLE mssgs (
    id mediumint(5) unsigned NOT NULL auto_increment, 
    uid tinyint(3) unsigned NOT NULL default '0', 
    m tinyint(2) NOT NULL default '0', 
    d tinyint(2) NOT NULL default '0', 
    y smallint(4) NOT NULL default '0', 
    start_time time NOT NULL default '00:00:00', 
    end_time time NOT NULL default '00:00:00', 
    title varchar(50) NOT NULL default '', 
    text text NOT NULL, 
    PRIMARY KEY (id) 
) ENGINE=MyISAM; 
+0

其實我讓它在createtable.php ... 當我按照你的提示有新的錯誤出來 # 1064 - 您的SQL語法錯誤;檢查與您的MySQL服務器版本對應的手冊,在第12行'TYPE = MyISAM'附近使用正確的語法 – 2012-04-15 17:39:01

+0

@JerungHidupKu:'TYPE'已被棄用, ENGINE'。 – 2012-04-15 17:50:48

+0

謝謝大家...真的很喜歡你們所有人的幫助... – 2012-04-15 18:10:59