Page 1 of 1

Weird characters in text

Posted: Wed Feb 17, 2010 12:15 am
by siko
Hi there,

I am rather new to PHP (to web programming actually), I am have a problem handling my text fields.

When I store a text field into mysql database and then retrieving them back, they are displaying weird characters like these

Image

and

Image

I am using htmlentities($field) before storing the data into mysql, and when I display the text with or without nl2br(html_entity_decode($field)), the characters are appearing that way.

I have copied those characters and pasted them into blogs like blogspot to look at the post and see what exactly those characters are, and realise that some of those characters are actually 'nothing', i.e. they are not expressed (simply not there).

I have tried changing between UTF-8 and ISO-8859-1 charsets but it seems they are not the solution to the problem (or maybe it had nothing to do with it.. I'm just trying everything..)

I have some thoughts that perhaps it may be the language of the user's computer/keyboard, but it is hard for me to test as I cannot get the users who had such problems input something again - my site is running live on the web and random people are coming in.

Does anyone have any advice?

Re: Weird characters in text

Posted: Wed Feb 17, 2010 2:41 am
by nblackwood
can you give a sample of the code you are using?

Re: Weird characters in text

Posted: Wed Feb 17, 2010 4:46 am
by dejvos
This usually occures when you have a bad charset in the column of database. I've this experience when I wanted to save UTF-8 text into a column which is in latin1 for example.

So you need to change a charset of the column in the db.

Good luck!