Welcome Guest, Not a member yet? Register   Sign In
Insert into database error with CI 1.6.1
#1

[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,
#2

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

I just tried CI 1.6.0, everything works fine.
#3

[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();
    }
#4

[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
#5

[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]
#6

[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]
#7

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

Thanks for that. Smile




Theme © iAndrew 2016 - Forum software by © MyBB