Knuckles Posted March 13, 2011 Share Posted March 13, 2011 Hello PHPFreaks, Im looking to make a script that can find sertend text or numbers in mysql database and can change it. The only problem is that the database also contains same text and numbers that dont need to be changed. So only for example within [39,10] the , has to be changed into a . and only between the [ ] Anyone got script for this or can help me make one cause im new to php. Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/ Share on other sites More sharing options...
sasa Posted March 13, 2011 Share Posted March 13, 2011 UPDATE table_name SET field = replace(field, '[39,10]', '.') http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1187106 Share on other sites More sharing options...
Knuckles Posted March 14, 2011 Author Share Posted March 14, 2011 This will not trigger anything else with a , to change into . ? Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1187270 Share on other sites More sharing options...
Knuckles Posted March 14, 2011 Author Share Posted March 14, 2011 UPDATE table_name SET field = replace(field, '[39,10]', '.') http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace The link doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1187296 Share on other sites More sharing options...
Knuckles Posted March 17, 2011 Author Share Posted March 17, 2011 This will not trigger anything else with a , to change into . ? Bump, anyone? Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1188586 Share on other sites More sharing options...
Knuckles Posted March 21, 2011 Author Share Posted March 21, 2011 UPDATE table_name SET field = replace(field, '[39,10]', '.') http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace Can this also be: UPDATE table_name SET field = replace(field, '[,]', '.') Cause the numbers are different for every product, so something need to allow the number to change. Would this code be good then or do i do something wrong? Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1190200 Share on other sites More sharing options...
sasa Posted March 21, 2011 Share Posted March 21, 2011 in that case you only can pull data out of database chenge it and put back to db Quote Link to comment https://forums.phpfreaks.com/topic/230531-find-and-change/#findComment-1190202 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.