Page 1 of 1

Problem while inserting special characters into mysql

Posted: Mon Aug 18, 2008 11:49 pm
by harshil
Hi,

I want to insert a paragraph in one field. But everytime I insert it inserts one the part before the special characters.

I had used htmlentities ,htmlspecialchars & other functions but not able to insert the whole paragraph. But it inserts upto "How do you get started?" only after that it doesn't insert.

the insert stmt:

$sql_query = "INSERT INTO internal_mail(mem_id,message) VALUES (".$mem_id.",'".html_entity_decode($body)."'";

and the $body message to insert is:

Welcome to Mysite.

I am here to help you.

How do you get started?

• The first thing to do is to invite your friends – then when they invite their friends you will all be connected and start having fun! Click Here to invite friends

• Edit your profile – Click Here to edit your Personal, Business and Social Profile

Re: Problem while inserting special characters into mysql

Posted: Tue Aug 19, 2008 1:01 am
by eskio
Hi,

First if you want to insert a big data (text), your field's type should be TEXT or MEDIUM TEXT.

I think, instead of
html_entity_decode($body)
use

Code: Select all

mysql_real_escape_string($body)