Page 1 of 1

problem with html tags

Posted: Fri Dec 01, 2006 6:27 am
by B.Murali Krishna
Hello ,

I have a problem with, special characters inserted into database. From some key boards the symbol '-' was bigger than normal. Although it was taken into database. But while reading some browser was't reading that Big "-".

the html equilant to that Big'-' will be &#8211 , How can i remove that Big "-" from database, and replaced with small '-' ie normal one.

i Have writted the code,

ereg_replace(&#8211 ,'-',$value);

But In the database, the filed $value does not have exactly – . There it was like that Big '-', From my key board i can't able to type that perticular character, even i tried combining two hiphans like '--', but it wont helped.

Please give any suggestions to remove that Big '-' from databse and replace normal one

Thank U,
Murali
PHP Programmer

Posted: Fri Dec 01, 2006 9:10 am
by aaronhall
It's probably one of "–" or "—" or "―". Just copy and paste these into str_replace() to filter these out of your forums. For the database, just cycle through the records, use str_replace() on the columns containing the long dashes, and update each row with the replaced dash.

Posted: Fri Dec 01, 2006 10:20 am
by GeertDD
Seems a bit more efficient to me to use MySQL's built in REPLACE() function.
REPLACE(str, from_str, to_str)

Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.

Code: Select all

mysql> SELECT REPLACE('www.mysql.com', 'w', 'Ww');
    -> 'WwWwWw.mysql.com'
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html