• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
db->insert Not Working

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>";
//echo "</pre>";

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


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


[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.

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.


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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.