Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    preg_replace causing to repeat

    I think the preg_replace is causing the former result to repeat:
    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";
        } 

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by gilgalbiblewhee View Post
    I think the preg_replace is causing the former result to repeat:

    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";
        }
    preg_replace isn't doing that ur concatenating it each time

    Code:
    $new = preg_replace("/[^ -ž]/", "", $old);
    just use this and you should be fine
    Last edited by shyam; 07-16-2008 at 06:55 PM.
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Yes the .= should be taken out. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •