Welcome Guest, Not a member yet? Register   Sign In
[resolved] Database Error When Creating Table
#1

[eluser]Unknown[/eluser]
I am receiving a Database Error when creating a table with dbforge. Any ideas?
Quote:A Database Error Occurred
Error Number: 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 ') DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci' at line 5

CREATE TABLE `PREF_Test` ( `Test_id` INT UNSIGNED AUTO_INCREMENT, `Test_uid` INT UNSIGNED, `Test_pref` VARCHAR ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Filename: C:\wamp\www\js\system\database\DB_driver.php

Line Number: 330

My code is:
Code:
public function create_pref_table($table,$type) {
        $this->load->dbforge();
        $fields = array(
            $table.'_id' => array(
                'type' => 'INT',
                'contraint' => 9,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ),
            $table.'_uid' => array(
                'type' => 'INT',
                'contraint' => 9,
                'unsigned' => TRUE
            ),
            $table.'_pref' => array(
                'type' => 'VARCHAR',
                'contraint' => 32
            )
        );
        $this->dbforge->add_field($fields);
        $this->dbforge->create_table('PREF_'.$table);
    }
#2

[eluser]danmontgomery[/eluser]
Code:
'contraint'
should be
Code:
'constraint'
#3

[eluser]Unknown[/eluser]
I looked for spelling mistakes for a good 5 minutes. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB