Problem while inserting special characters into mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
harshil
Forum Newbie
Posts: 13
Joined: Fri Aug 01, 2008 1:21 am

Problem while inserting special characters into mysql

Post 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
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Re: Problem while inserting special characters into mysql

Post 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)
Post Reply