Hello JSaur,

Here is a php script i whipped up for you.  Hope it helps

Please Please PLEASE update your data before running this script.
I have tried a version of this on a data table here but changing
column names etc for testing the changing back can always lead to 
some error.

One thing you could do if you want is put 'print' statements in
among the processes to see what is happening .. IF there seems
to be any error.

I have included error messages if the Mysql scripts act up.

DSig

-------- cut here -------
<html>
<body>

<?

 //Create persistent connection
 $link = mysql_pconnect('yourservername', 'yourdbuser', 'yourdbuserpassword' );

/*
    this is your primary selection of data to modify.  Here I have
    use = but you might want to use LIKE instead.
*/
 $sql_query = "SELECT c1,c2,c3 FROM yourtablename 
    where c2 = 'women with hammer'
    OR c3 = 'women with hammer'";

/*
    Here we do the query against the database.  IF there is any problem the DIE
    section will print out the mysql error number and string along with the 
    script that is being sent to mysql
*/
 $res = mysql_db_query('youtablename', $sql_query) or 
    DIE ("MySQL gave error: " . mysql_errno() . "<br>MySQL Error String: " . 
mysql_error()
          . "<br>Query: " . $sql_query);

/*
    Now we will start going through the rows selected.  Then for each
    break out the column data, use ereg_replace to brute force the change
    then use an update query to do the update.  Using c1 as the ID .. 
    
    Once again .. any errors should be printed out for examination
*/
while ($row = mysql_fetch_array($res))
    {
        $c1 = $row["c1"];
        $c2 = $row["c2"];
        $c3 = $row["c3"];
        
        $newc2 = ereg_replace("women with hammer","women WITH hammer",$c2);
        $newc3 = ereg_replace("women with hammer","women WITH hammer",$c3);
        
        $query = "UPDATE 'yourtablename' set c2='$newc2',c3='$newc3' where c1 = '$c1'";

        $res2 = mysql_db_query('ssoft', $update_query) or 
           DIE ("MySQL gave error: " . mysql_errno() . "<br>MySQL Error String: " . 
mysql_error()
             . "<br>Query: " . $update_query);
    }

echo ("done");
?>

</body>
</html>



Thursday, September 20, 2001, 8:34:53 AM, you wrote:

Jec> Hello there,

Jec> could you please help to a novice...

Jec> I have table

Jec> c1,c2,c3
Jec> '1' , 'man with hammer' , 'woman with hammer'
Jec> '2' , 'woman with hammer' , 'man with hammer'

Jec> where cX are column names.

Jec> And now I need to update database and change string 'with' to 'WITH'. But
Jec> just for women.

Jec> Thanks a lot for your help.


-- 
Best regards,
 Igbar                            mailto:[EMAIL PROTECTED]



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to