Jump to content

Problems with preg_replace error in my code - since php 5.2.5 upgrade


Recommended Posts

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  ;D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.