Jump to content

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


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]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.