On 18 April 2010 16:40, Phpster <phps...@gmail.com> wrote:
>
>
> On Apr 18, 2010, at 8:59 AM, Michael Stroh <st...@astroh.org> wrote:
>
>> I have this form that people use to add entries into a MySQL database.
>> Recently I've had some users insert − in their entries instead of - which is
>> causing some issues with scripts down the line. I'd like to replace the −
>> character with -.
>>
>> Originally I had something like
>>
>> $name = mysql_escape_string($_POST["name"]);
>>
>> which would convert the offending character to &#8722; before entering it
>> into the database. It's this encoding that is causing the problems since
>> some scripts send out emails with this entry in their subject line which
>> looks messy.
>>
>> I've tried adding the following line after the previous line to help fix
>> this issue, however, I just got another entry with the same problem.
>>
>> preg_replace('/&#8722;/','-',$name);
>>
>> Any suggestions on how others would fix this problem? I'd just like to fix
>> it before the entry hits the database instead of creating fixes on the other
>> end of things.
>>
>>
>> Cheers,
>> Michael
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> One option is to send an HTML email which would have the email reader
> interpret that code correctly
>
> Bastien

Another option would be to use mysql_real_escape_string and make sure
that your code and the database are using utf-8. Then when the email
is sent, make sure that uses utf-8 as well.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to