Results from the most recent live auction are here .
21 members in the live chat room. Join Chat !
06-04-2006, 05:12 PM
· #1 Senior Member
Name: Zubair
Location: Ontario Canada
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (
Donate )
checking for certain chars?
Hey
Can anyone help me do this:
I am trying to check for specific characters in a string..and if they are there...i want it to give an error...i want to check the string "$username" and check for everything that is not a alphanumberical char...
so if it contains ";" or "," or ":" or "}" etc..i want it to give an error
can anyone help me out...
06-04-2006, 05:24 PM
· #2 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
PHP Code:
<?php
if ( preg_match ( "/([^a-z0-9]+)/i" , $string ))
{
die( 'Error: string can only contain letters (a-z) and numbers (0-9)' );
}
?>
06-04-2006, 05:50 PM
· #3 DNOA Member
Location: Iowa
Join Date: Jun 2004
Posts: 655
NP$: 13.10 (
Donate )
Originally Posted by SecondVersion PHP Code:
<?php
if ( preg_match ( "/([^a-z0-9]+)/i" , $string ))
{
die( 'Error: string can only contain letters (a-z) and numbers (0-9)' );
}
?>
don't you need the ! in !preg_match?
__________________
Want to prove yourself?
CHECK OUT MY DOMAINS!
06-04-2006, 06:01 PM
· #4 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
No, he did ([^... the ^ means not those characters.
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off