Storing Special Characters in Table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ummarbhutta
Forum Newbie
Posts: 9
Joined: Sun Nov 23, 2008 7:12 am

Storing Special Characters in Table

Post by ummarbhutta »

Hi all!
I am having provlem storing special characters in to Database table.. I have a table named messages having following structure

MESSAGE_ID bigint(20)
Catagory_ID int(11)
Message text

The table Collation is "utf8_unicode_ci" and also the Message field's collation is "utf8_unicode_ci", but when I store a Message e.g.

but when I store any special character in Message field like “ and ` they are stored like %20xx etc etc.. and being displayed on HTML as %20xx etc.. whcih doesn't seem good.. Please help me out. how to solve this problem.. My Table storage engine is "InnoDB".. Please I need quick help..
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Storing Special Characters in Table

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
ummarbhutta
Forum Newbie
Posts: 9
Joined: Sun Nov 23, 2008 7:12 am

Re: Storing Special Characters in Table

Post by ummarbhutta »

This is about URL Encode.. I am having problem storing it in DB? Will it solve the problem.. I think there is problem in Insert Query.. ?? Should I use some escape sequences?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Storing Special Characters in Table

Post by VladSun »

I think your $Message is URL encoded.
There are 10 types of people in this world, those who understand binary and those who don't
ummarbhutta
Forum Newbie
Posts: 9
Joined: Sun Nov 23, 2008 7:12 am

Re: Storing Special Characters in Table

Post by ummarbhutta »

Ok I will try it.. you are saying that before storing in DB I should URL encode it?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Storing Special Characters in Table

Post by VladSun »

ummarbhutta wrote:Ok I will try it.. you are saying that before storing in DB I should URL encode it?
No, just the opposite - you should decode it.

Code: Select all

$Message = mysql_real_escape_string(urldecode($Message));
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply