MySQL表创建错误(语法对我来说很好)

时间:2012-04-16 17:46:01

标签: mysql

任何人都可以弄明白我在做错了什么吗?错误信息相当含糊......

16-Apr-2012 17:36:42] WordPress database error 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 '' at line 24 for query CREATE TABLE wp_psadata(
    id INTEGER(10) UNSIGNED AUTO_INCREMENT,
    date_entered TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    submitter_name VARCHAR(255),
    submitter_email VARCHAR(255),
    submitter_phone VARCHAR(255),
    event_name VARCHAR(255),
    location_name VARCHAR(255),
    address VARCHAR(255),
    city VARCHAR(255),
    state VARCHAR(255),
    zipcode VARCHAR(5),
    phone VARCHAR(255),
    email VARCHAR(255),
    uri VARCHAR(255),
    event_start_date DATE,
    event_start_time TIME,
    event_end_date DATE,
    event_end_time TIME,
    recurs_on_dow TINYINT,
    description VARCHAR(4000),
    comments VARCHAR(4000), 
    active TINYINT DEFAULT 1,
    wants_reach_at_event TINYINT DEFAULT 0 made by activate_plugin, do_action, call_user_func_array, psa_activate, dbDelta

使用:SQLite版本2.8.17 - 3.7.4 / PHP版本5.3.6

谢谢!

编辑:

这是我在PHP中的实际代码。上面的代码来自日志,因此可能缺少一些东西:

$sql = 'CREATE TABLE '. $table_name . '(
    id INTEGER(10) UNSIGNED AUTO_INCREMENT,
    date_entered TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    submitter_name VARCHAR(255),
    submitter_email VARCHAR(255),
    submitter_phone VARCHAR(255),
    event_name VARCHAR(255),
    location_name VARCHAR(255),
    address VARCHAR(255),
    city VARCHAR(255),
    state VARCHAR(255),
    zipcode VARCHAR(5),
    phone VARCHAR(255),
    email VARCHAR(255),
    uri VARCHAR(255),
    event_start_date DATE,
    event_start_time TIME,
    event_end_date DATE,
    event_end_time TIME,
    recurs_on_dow TINYINT,
    description VARCHAR(4000),
    comments VARCHAR(4000), 
    active TINYINT DEFAULT 1,
    wants_reach_at_event TINYINT DEFAULT 0;
    PRIMARY KEY  (ID) )';

1 个答案:

答案 0 :(得分:4)

修改

这一行后面有一个分号,这是一个mysql语句分隔符。

wants_reach_at_event TINYINT DEFAULT 0; <--

您可能认为它是逗号,

wants_reach_at_event TINYINT DEFAULT 0,
PRIMARY KEY  (ID) )';