worldcomingtoanend Posted October 9, 2009 Share Posted October 9, 2009 I tried to replace eregi with preg_match and I got this error; Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in But i am confused as to how to write the delimiter part of it. a more clearer code is here below: foreach($bad_strings as $bad_string) { if(eregi($bad_string, strtolower($str_to_test))) { echo "$bad_string found. Suspected injection attempt - mail not being sent."; exit; Link to comment https://forums.phpfreaks.com/topic/177083-solved-rewrite-iferegibad_string-strtolowerstr_to_test-using-preg_match/ Share on other sites More sharing options...
Mark Baker Posted October 9, 2009 Share Posted October 9, 2009 if(preg_match('/'.preg_quote($bad_string,'/').'/i', strtolower($str_to_test))) { Link to comment https://forums.phpfreaks.com/topic/177083-solved-rewrite-iferegibad_string-strtolowerstr_to_test-using-preg_match/#findComment-933685 Share on other sites More sharing options...
cags Posted October 9, 2009 Share Posted October 9, 2009 Depends on the content of bad strings, are they actually regex patters or just strings? If they are just strings... <?php foreach($bad_strings as $bad_string) { if(stristr($input, $bad_string)) { echo "$bad_string found. Suspected injection attempt - mail not being sent."; exit; } } ?> If they are infact regular expressions then you'd need to do something like... <?php foreach($bad_strings as $bad_string) { if(preg_match("~$bad_string~i", $input)) { echo "$bad_string found. Suspected injection attempt - mail not being sent."; exit; } } ?> Nb: Untested. Link to comment https://forums.phpfreaks.com/topic/177083-solved-rewrite-iferegibad_string-strtolowerstr_to_test-using-preg_match/#findComment-933686 Share on other sites More sharing options...
worldcomingtoanend Posted October 9, 2009 Author Share Posted October 9, 2009 Thank you people for your support and help. everything seems to work now. Link to comment https://forums.phpfreaks.com/topic/177083-solved-rewrite-iferegibad_string-strtolowerstr_to_test-using-preg_match/#findComment-933715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.