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, 09:41 AM
Registered User
 
Join Date: Jul 2004
Posts: 221
finding and replacing strings in database

I'm trying to find which function fits the script. My objective is to find all the records where there are   including the misspellings (nbsp;, nbsp, &nbsp) and replace them with the space bar " ":
PHP Code:
$sql "SELECT * FROM ".$acronym."_pages WHERE content LIKE '%nbsp%'";
$result mysql_query($sql) OR exit( 'Error: ' mysql_error() );
    
//echo $sql;
    
function nbspSearch(){
        
//insert code here
    
}
    while(
$row mysql_fetch_array($result)){
        
sql2 "UPDATE ".$acronym."_pages SET content = '".str_replace(nbspSearch(), " "$row['content'])."' WHERE content = '".$row['content']."'";
    }
mysql_close($con); 
If anyone has a better suggestion than mine let me know. Thanks.
Reply With Quote

  #2 (permalink)  
Old 07-15-2008, 05:19 PM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 266
Send a message via MSN to Deadeye
it looks like thats good enough. If you're going to run this constantly, and your database is able to run stored procedures then I would recommend writing one of those. But if your use mysql then you way of doing that is good.

Wesley
__________________
Don't forget to rate me A+++++++++++++++++!!!!!111one for the service you have received.
Reply With Quote
  #3 (permalink)  
Old 07-16-2008, 12:43 PM
Registered User
 
Join Date: Jul 2004
Posts: 221
Ok thanks it works.
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


All times are GMT -5. The time now is 10:00 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