Welcome Guest, Not a member yet? Register   Sign In
db->insert Not Working
#1

[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 );
#2

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

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB