FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Rejecting Certain Non-ASCII Characters
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Rejecting Certain Non-ASCII Characters [message #181155 is a reply to message #181149] Fri, 19 April 2013 17:38 Go to previous messageGo to previous message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma:
Member
Jim Higgins wrote:
> I have a problem with people entering a slashed zero vs a standard
> ASCII zero into HTML forms intended to store data in a MySQL database.

Is it really a slashed zero (U+0030 U+0338) they're entering, or do they
enter some similar looking character such as the Danish Ø? In the
former case you can simply replace the slashed zero with a standard
zero. Assuming UTF-8 encoding:

$input = str_replace('\xCC\xB8', '', $input);

> Is there a simple way in PHP to restrict input to the ASCII Character
> set, specifically hex 0x20 - 0x7E ? Or a simple way to detect
> characters outside this range before committing them to the database?

If you're dealing with a numeric column, you may consider checking for
is_numeric().

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: googleapi problem
Next Topic: Undefined variable
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 16:41:16 GMT 2024

Total time taken to generate the page: 0.04340 seconds