Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a plugin that creates tables and one of them is failing and I feel like it's due to either my syntax or the fact that I'm trying to create a column with datatype DATE and not TIMESTAMP (only one that I can make work). Can someone look at my syntax below and tell me what is wrong?

$table = $wpdb->prefix.SSM_ACADEMIC_YEAR_TABLE;

        $sql =  "CREATE TABLE IF NOT EXISTS " . $table . " (
                  id mediumint(12) NOT NULL AUTO_INCREMENT,
                  description VARCHAR(200) NOT NULL,
                  begin_date DATE NOT NULL, 
                  end_date DATE NOT NULL
                PRIMARY KEY (id));";

    $wpdb->query($sql);

and now just looking at the other field in question, is it possible that it doesn't like VARCHAR(200)? Having issues here and running out of steam and time. Any help would be greatly appreciated!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Well, after looking at the other tables I had created successfully, only difference was the description column. Apparently WordPress or MySQL doesn't like that as a column name and somehow has it reserved. So, after renaming it, the table was created fine. Hope this helps someone else in the same boat.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.