
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  from  authoritative  sources  showing  the ', ' 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";
}
|