I try to save / update data with text “…That means you may insert keywords into the title of a page where ever …..” It shows 500 internal server error, and when I save without “insert” word in above text it easily saves in database. The same thing happens when I use the reserved words like update, delete in the field to add/update in the database. The error is due to the reserved word of mysql, isn’t there any ways to get rid of it?
I am using CodeIgniter and code to update above text is :
function update_template($id,$newtext,$newcomptext)
{
$data=array(
'option_value'=>$newtext,
'competitive_value'=>$newcomptext
);
$this->db->where('id', $id);
$this->db->update('report_texts', $data);
return 'Successfully Updated';
}
I would be much thankful for the help.
It’s likely that the word “INSERT” in the text you’re writing to the database is causing an SQL error (INSERT is generally a reserved word in SQL implementations).
In any case, the CI framework says, “Oh, we have a problem. I should return a 500 error message” as a result of the error it gets back from the database.
EDIT
The $this->db->escape() function doesn’t help this because $this->db->query() already escapes your values.