JSaur,
>Hello Igbar,
>
>thank you for your script.
>Bud I need to change just word "with". Woman with hammer was just example.
>There is text about 1000 words in one fied, and I need to change just a
>short string.
>I show you another example.
>
>CREATE TABLE my_table(c1 int NOT NULL PRIMARY KEY, c2 blob);
>INSERT INTO my_table VALUES (1, ' I have got a new car. And it is a
><b>BIG</b> car.');
>
>SELECT REPLACE(c2, '<b>big</b>', '<i>small</i>')
>
>That's what I wont to do. Bud it change just result on screen. I need to
>update this result back to dabatase.
First .. I am putting this back on the list for 2 reasons ..
1) Completeness of the thread. Others might search for the same type
of answer and this will allow better answers to be found.
2) Mail comes back from your server saying your account is disabled.
Okay ..
Basically it would work the same weather you want to change a long
string or a short string.
First in your 'SELECT' query you would simply change to a LINE (as i
hinted at in the comments). So something like
/*
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 like '%with%'
OR c3 like '%with%'";
One thing to think about this is that it will find 'with' as well as
'without'. If you *know* your data you might change this to
where c2 like '% with %'
OR c3 like '% with %'";
That is the problem with computers .. they are pretty literal <G>
Now for the update part it would be very similar .. you just need to
define the "from string" and the "to string"
$newc2 = ereg_replace(" with "," WITH ",$c2);
$newc3 = ereg_replace(" with "," WITH ",$c3);
just be sure to make the 'to string' (second parameter) all the data
you want replaced. Example:
if your data was "women with hammer" and you did
$newc2 = ereg_replace(" with ","WITH",$c2);
your resulting data would be "womenWITHhammer" because the 'to string'
did not contain the spaces.
So at the end of the day you have to know exactly what you want to
change AND exactly what you will change it to.
Hope this helps.
--
Best regards,
Igbar mailto:[EMAIL PROTECTED]
--
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