Reputation: 107
I'm using $this->db->escape
in before inserting data in my db, however, when I query the db for that data, I'm having problems getting rid of the quotes.
I'm using str_replace("'", "",$p->post_text);
but it removes all the single quotes as expected. If $p->post_text
is a string like "I'm not gonna work for mary's brother no more"
it will remove those as well. I noticed that the a backslash is added to single quotes that are on the the string and not on the ones generated by php.
So I tried :
$post_text = str_replace("'", "",$p->post_text);
$post_text1 = stripslashes($post_text);
Still not working. I guess the slashes are stripped automatically.
Any help will be appreciated.
UPDATED ADDED INSERT QUERY:
$data = array('aluno_id' => $myid,
'post_text' => $this->db->escape($text),
'post_image' => $this->db->escape($img),
'youtube_link' => $this->db->escape($video_code),
'media_top' => $this->db->escape($media_top),
'post_date' => date(date('Y-m-d H:i:s'))
);
$this->db->insert('mutamba_posts',$data);
Upvotes: 2
Views: 1962
Reputation: 372
Although its an old question but no solution so i add this.
Try using
$this->db->escape_str($YOUR_STRING);
Upvotes: 4