Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2008, 11:40 PM
Registered User
 
Join Date: Jul 2004
Posts: 224
preg_replace causing to repeat

I think the preg_replace is causing the former result to repeat:
Quote:
INSERT INTO correction_nbsp (bwas_pages_id, content_before, content_after) VALUES (702, 'chapter: ', ' CHAPTER 1 chapter: ')
INSERT INTO correction_nbsp (bwas_pages_id, content_before, content_after) VALUES (711, 'copies &nbspfrom &nbspauthoritative &nbspsources &nbspshowing &nbspthe ', ' CHAPTER 1 chapter: copies from authoritative sources showing the ')
INSERT INTO correction_nbsp (bwas_pages_id, content_before, content_after) VALUES (714, 'told what the truth is, and still not see it. ', ' CHAPTER 1 chapter: copies from authoritative sources showing the told what the truth is, and still not see it. ')
INSERT INTO correction_nbsp (bwas_pages_id, content_before, content_after) VALUES (716, 'see it? ', ' CHAPTER 1 chapter: copies from authoritative sources showing the told what the truth is, and still not see it. see it? ')
PHP Code:
while($row mysql_fetch_array($result)){
        
$old preg_replace('#&?nbsp;?#i'' '$row['content']);
        
$new .= preg_replace("/[^ -þ]/"""$old);
        
$sql_record2 "INSERT INTO correction_nbsp (".$acronym."_pages_id, content_before, content_after)
        VALUES ("
.$row['id'].", '".$row['content']."', '".$new."')";
        
mysql_query($sql_record2,$con) or die(mysql_error());
        echo 
$sql_record2."<br />\n";
    } 
Reply With Quote

  #2 (permalink)  
Old 07-16-2008, 05:28 AM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,399
That's because you're adding to the $new variable, rather than reinstantiating it each time. Get rid of the dot in front of the equal sign in this line:
PHP Code:
$new .= preg_replace("/[^ -þ]/"""$old); 
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #3 (permalink)  
Old 07-16-2008, 12:41 PM
Registered User
 
Join Date: Jul 2004
Posts: 224
Quote:
Originally Posted by curtiss View Post
That's because you're adding to the $new variable, rather than reinstantiating it each time. Get rid of the dot in front of the equal sign in this line:
PHP Code:
$new .= preg_replace("/[^ -þ]/"""$old); 
Oh yeah that's true.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is It Possible To Create A Header That Will Repeat? curtiss Programming and Scripting 3 09-12-2005 08:40 AM


All times are GMT -5. The time now is 11:33 PM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter