Welcome to WebmasterWorld Guest from 54.226.133.245

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

ereg_replace stopped working

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

Full Member

10+ Year Member

joined:Aug 2, 2003
posts:288
votes: 0


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.

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

Administrator

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

joined:July 31, 2003
posts:12533
votes: 0


Are you getting any errors? Turn on error_reporting [php.net] to see.
2:54 pm on Feb 28, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Aug 2, 2003
posts:288
votes: 0


Error reporting displays "2039".
5:08 pm on Feb 28, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Aug 2, 2003
posts:288
votes: 0


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

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

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

Administrator

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

joined:July 31, 2003
posts:12533
votes: 0


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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members