Jump to content

Recommended Posts

I have a problem with user text input. If the user enters (for example) £ or ¬ into the text area and submits the data, this is what I get:

 


1. print_r($_POST);

Array

(

    [add_post] => £

¬

)

 

2. $content = htmlentities($_POST['add_post']);

£

 

3. $content_mysql = mysql_real_escape_string($content);

¬£\r\n¬


 

When I call the information out of the database, I get wierd symbols displayed on the page. The Collation to store the data is utf8_bin. Whats going on?

 

Cheers,

Joe

Link to comment
https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/
Share on other sites

Weird symbols how?

 

The two symbols above (the £ and the ¬) are the only two 'standard' symbols which have this problem. They are both replaced with à (code, Â) and then there symbol, i.e. ì or ã. If another user then quotes this text and posts it the output is the à followed by a diamond with a question mark in it � (the wierd one) followed by the previous two symbols, i.e. Ã�ì or Ã�ã. If this text then gets quoted upside down question marks, i's with two dots and more unusual symbols appear. The loop could essentially carry on forever. I have tested a few alt + number symbols and they too have a similar output.

 

Is there a solution to this? If it was just the two symbols a str_replace would be fine (although I would not completely remove the symbol), but thanks to the option of European keyboards with umlauts and all sorts of different symbols I need a solution.

 

Cheers, Joe.

 

p.s. My mysql server version is 5.0.91

After some thorough research it is solved. The following meta tag was where the problem was at:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

The charset needed changing to ISO-8859-1.

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

 

According to this article, the reason is because utf-8 will only convert the first 128 character codes whereas ISO-8859-1 will covert all western latin characters.

 

However, just a little further down in the article (the second note of this section), he mentions that if you don't declare the meta tag before the title tag the browser will decide it for you. A little bit curious, I tested this by not declaring the meta tag anywhere on the script. The script then displayed all the characters perfectly in IE7.8.9, FF4, Chrome, Safari and Opera.

 

So my question is, is there any point in declaring it in modern day browsers?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.