and1c Posted December 31, 2007 Share Posted December 31, 2007 ok guys, Im still learning PHP and this has thrown me! Since I upgraded my server (centos) to latest apache, mysql and php (5.2.5) I am getting this error when I try and submit some information through a form in my sites admin panel PHP Warning: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Unknown modifier 'a' in /var/www/html/mysite/functions/main.php on line 224, referer: http://www.mysite.com/SessID I have been playing around adding "/" at the beginning and end of the pattern but I cannot seem to fix it!! function bx_unhtml_tags($str){ if(ALLOW_HTML_TAGS == "yes") { $patterns = array(); $replacement = array(); $taglist = split(",",trim(HTML_TAG_LIST)); for ($i=0;$i<sizeof($taglist);$i++) { if(trim($taglist[$i])!='') { $patterns[] = "/".htmlspecialchars(eregi_replace(">","(.*?)>",strtolower(trim($taglist[$i]))))."/mi"; //suspect code I changed **original code is here**// $patterns[] = "/".htmlspecialchars(eregi_replace("<","<\/",eregi_replace(">","[\s]?> ",trim($taglist[$i]))))."/mi"; $replacement[] = strtoupper(str_replace(">","\\1>",trim($taglist[$i]))); $replacement[] = eregi_replace("<","</",strtoupper(trim($taglist[$i]))); } } $str = preg_replace($patterns, $replacement, $str); } if(ERASE_HTML_TAGS == "yes") { $patterns = array(); $replacement = array(); $taglist = split(",",trim(ERASE_TAG_LIST)); //Error Line// for ($i=0;$i<sizeof($taglist);$i++) { if(trim($taglist[$i])!='') { $patterns[] = "/".htmlspecialchars(eregi_replace(">","(.*?)>",strtolower(trim($taglist[$i]))))."/mi"; $patterns[] = "/".htmlspecialchars(eregi_replace("<","<\/",eregi_replace(">","[\s] <?php",trim($taglist[$i]))))."/mi"; $replacement[] = ""; $replacement[] = ""; } } Basically it is for a form in my admin panel whereby I can alter or add an advert to my site. Since the upgrade one field in the form (advert description) is not saving and all appears ok, bu the advert has no body content. The error being logged is clearly showing that the html code checker (to remove html tags to prevent spam) is causing the problem. However it always worked perfectly before! can anyone point me in the direction of a fix for this please? thanks and hapy new year in advance Quote Link to comment https://forums.phpfreaks.com/topic/83835-problems-with-preg_replace-error-in-my-code-since-php-525-upgrade/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.