cheverst Posted January 25, 2011 Share Posted January 25, 2011 Hi all, first time here as I am a bit stuck. I am by no means a programmer and I was hoping that someone out there may have a simple solution to my problem?... So here goes" I have a voucher/offers site up-and-running. The site content is generated from an external feed. I want to create other sites and I want to track what sales/clicks have come from where. An example of the feed: (http://www.awin1.com/awclick.php?mid=251&id=28971&clickref=[url_REFERENCE]&p=http://www.247electrical.co.uk) As you will see, I have [url_REFERENCE] in each link. I want to automatically change that part of the string in the database. Does anyone have any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/225633-can-i-use-a-cron-job-to-search-and-change-part-of-a-string-in-sql/ Share on other sites More sharing options...
taquitosensei Posted January 25, 2011 Share Posted January 25, 2011 in your mysql client update table set field=replace(field,"[url_REFERENCE]",""); if you want to get ride of the &p= also update table set field=replace(field,"[url_REFERENCE]&p=",""); I would try it on some test data first to make sure the brackets and ampersand don't screw anything up. I just noticed you said cron job. You could have a php script run this then use a cron job to run the php script. Quote Link to comment https://forums.phpfreaks.com/topic/225633-can-i-use-a-cron-job-to-search-and-change-part-of-a-string-in-sql/#findComment-1165044 Share on other sites More sharing options...
cheverst Posted January 25, 2011 Author Share Posted January 25, 2011 Thanks for the info. Now that I have thought about it, I hope there may be an easier route. I have attached a file that executes the database import. Can you suggest a line of code that searches and replaces the [url_REFERENCE] in the string as it is or after it is working? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/225633-can-i-use-a-cron-job-to-search-and-change-part-of-a-string-in-sql/#findComment-1165058 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.