joe92 Posted April 21, 2011 Share Posted April 21, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/ Share on other sites More sharing options...
fenway Posted April 24, 2011 Share Posted April 24, 2011 Weird symbols how? Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1205576 Share on other sites More sharing options...
nzol Posted April 25, 2011 Share Posted April 25, 2011 If you want to filter these out, you could use: $data = $_POST['data']; $newdata = str_replace($data , " ", "£"); //this replaces any occurences of £ with a space Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1205763 Share on other sites More sharing options...
joe92 Posted April 26, 2011 Author Share Posted April 26, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1206322 Share on other sites More sharing options...
fenway Posted April 26, 2011 Share Posted April 26, 2011 Perhaps you're seeing unicode issues. Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1206397 Share on other sites More sharing options...
joe92 Posted April 26, 2011 Author Share Posted April 26, 2011 Perhaps you're seeing unicode issues. By this, do you mean the collation of the database? Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1206400 Share on other sites More sharing options...
joe92 Posted April 26, 2011 Author Share Posted April 26, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1206485 Share on other sites More sharing options...
fenway Posted April 27, 2011 Share Posted April 27, 2011 Not if you're using standard common Western character sets, no. Quote Link to comment https://forums.phpfreaks.com/topic/234331-symbols-being-prefixed-with-acirc/#findComment-1206873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.