homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
ereg_replace stopped working
roitracker




msg:1281323
 2:05 pm on Feb 28, 2005 (gmt 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.

 

coopster




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

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

roitracker




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

Error reporting displays "2039".

roitracker




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

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

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

coopster




msg:1281327
 5:34 pm on Feb 28, 2005 (gmt 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 ;)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved