problem with html tags

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
B.Murali Krishna
Forum Commoner
Posts: 28
Joined: Fri May 12, 2006 2:05 am
Location: Hyderabad,India
Contact:

problem with html tags

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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.
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post 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
Post Reply