CodeIgniter Forums
db->insert Not Working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: db->insert Not Working (/showthread.php?tid=35532)



db->insert Not Working - El Forum - 11-02-2010

[eluser]wynnewade[/eluser]
After creating an associative array of values, I am calling $this->db->insert( 'career_jobpostings', $newPost );

This does NOT produce any errors NOR does it produce a new database record.

I am retrieving data from the database so I feel that my database.php is set correctly.

and the ONLY field in the database that I am NOT including in the array is the primary key field which is set to auto-increment. When I dump the array, all values are correct.

I have been at this for hours and cannot find the issue. Please help!

controller code below
----------
$newPost = array(
'postDate' => date( "Y-m-d" ),
'closeDate' => $this->input->post('closeDate'),
'jobTitle' => $this->input->post('jobTitle'),
'jobLocation' => $newJob['jobLocation'],
'jobCity' => $newJob['jobCity'],
'jobState' => $newJob['jobState'],
'positionSummary' => $newJob['positionSummary'],
'positionQualifications' => $newJob['positionQualifications'],
'summarySheet' => 'thisFile.pdf',
'openStatus' => $this->input->post('postStatus'),
'infoURL' => 'http://www.edrtrust.com',
'lastEdited' => date( "Y-m-d h:iConfused" )
);

//echo "<pre>";
//var_dump($newPost);
//echo "</pre>";

$this->db->insert( 'career_jobpostings', $newPost );


db->insert Not Working - El Forum - 11-02-2010

[eluser]smilie[/eluser]
Hi,

Could you please post complete code (including database connection and everything)?

Also, please use CODE with [] brackets, as it is then easier to read Smile

Cheers,
Smilie


db->insert Not Working - El Forum - 11-02-2010

[eluser]Mad Maurice[/eluser]
add an

echo $this->db->last_query();

and comment any redirects.
this will output the SQL Command codeigniter generated,
so you can see if its correct.


db->insert Not Working - El Forum - 11-02-2010

[eluser]Christophe28[/eluser]
When CI doesn't throw you a DB error it is probably because you want to insert for example TEXT in a column which only accepts integers. Be sure (again for example) that the column 'infoURL' has VARCHAR(100), or that column 'lastEdited' is able to store dates.

Christophe


db->insert Not Working - El Forum - 09-27-2014

[eluser]Unknown[/eluser]
I struggled with this for probably six hours, and it drove me nearly insane.

My solution was to set default values for each column in the data table that the insert function was operating on.