0

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!

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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