Welcome to WebmasterWorld Guest from 50.19.34.234

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

ereg_replace stopped working

     

roitracker

2:05 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



This works fine on one server, but not on another server (both use 4.1.3). The pattern does not appear to be being identified on the new server, so the replacement text is not being added to the output.

$pattern = "href=\"";
$replacement = "href=\"http://mylink.com/click.php?id=$_POST[id]&url=";
$entry = eregi_replace($pattern,$replacement,$entry);

echo "$entry";

Basically it should replace <a href="http://mysite.com">My link</a> with <a href="http://mylink.com/click.php?id=$_POST[id]&url=http://mysite.com">My link</a>

Any help appreciated.

coopster

2:13 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Are you getting any errors? Turn on error_reporting [php.net] to see.

roitracker

2:54 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



Error reporting displays "2039".

roitracker

5:08 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



str_replace works just as well, so I'll use it instead:

$entry = str_replace("href=\\\"",$replacement,$entry);

coopster

5:34 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It seems about the only thing you aren't showing are E_NOTICE [php.net] errors. I'm not sure what type of error would be thrown if the POSIX regular expressions [php.net] weren't configured in your second installation. You could always run the phpinfo() [php.net] function to have a look at the Configure Command on your server to see if the extension has been loaded.

But, if str_replace is working for you, good enough ;)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month