CodeIgniter Forums

Full Version: Insert into database error with CI 1.6.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]123XD[/eluser]
Hi,

I am just update CI from 1.54 to 1.61, and the database insertion not working,
it works for 1.54, I am using MSSQL 2005.

The view page is a simple form, and in the controller I just simply get 3 post variables and in controller i am using

Code:
$data = array
    (
      'Firstname' => $firstname, //$firstname data retrieve from form
      'Lastname' => $lastname,
      'Email' => $email
    );
    $this->db->insert('Demo', $data);

this brings me a error as followd
and the error as followed

Code:
INSERT INTO "Demo" ("Firstname", "Lastname", "Email") VALUES ('User', 'Tmp', '[email protected]')

I paste it into MSSQL 'new query' and execute it, it works. Anyone have any ideas??
I think it's the problem with the double quotes around the table name, but i don't know how to fix it.

Cheers,

El Forum

[eluser]123XD[/eluser]
well, maybe there are some bugs for 1.6.1

I just tried CI 1.6.0, everything works fine.

El Forum

[eluser]gtech[/eluser]
I use 1.6.1 and have no problems with inserts.. What is the actual error message? and what driver are you using?
Code:
$dbRet = $this->db->insert($table, $data_array);
    if (!$dbRet) {
      // will only get this far if db_debug is false.
      // otherwise it will be displayed on the browser automatically.
      echo $this->db->_error_message();
      echo $this->db->_error_number();
    }

El Forum

[eluser]123XD[/eluser]
Quote:An Error Was Encountered
Error Number:

INSERT INTO "Demo" ("Firstname", "Lastname", "Email") VALUES ('User', 'Tmp', '[email protected]')

that's all i got from the error, it does not have a error number,
driver?? mssql driver

El Forum

[eluser]gtech[/eluser]
sincere apologies I misread the database you are using, I have not used MSSQL before so may be very little help (I asked about the driver in case you may of accidentally used the wrong one in the database config).

[edit] found problem below [/edit]

El Forum

[eluser]gtech[/eluser]
ooo.. this thread might help it highlights the double quote problem.

[url="http://ellislab.com/forums/viewthread/73664/"]http://ellislab.com/forums/viewthread/73664/[/url]
and
[url="http://ellislab.com/forums/viewthread/71558/#353513"]HERE IS THE FIX[/url]

El Forum

[eluser]123XD[/eluser]
cool~~

Thanks for that. Smile