Jump to content

Can I use a cron job to search and change part of a string in sql?


cheverst

Recommended Posts

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?

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.

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.