I am an affiliate for a some merchants. I receive a data download from via FTP. I then upload the products into MySQL. Currently I have to open the files in notepad and do a find and replace to correct the url to represent my affiliate info. This can be quite time consuming and cumbersome, considering some of these files are several hundred MBs.

So...is it possible to change, while the page is being generated, a url. For instance, the field may have something like http://affiliates.art.com/get.art?T=[TrackID Here]&A=[AffiliateID Here]&L=.... I would like it change this url to something like http://affiliates.art.com/get.art?T=12345A=67891&L=

Basically to replace the [TrackID Here] and [AffiliateID Here] with a numeric values that are defined in the code of the page.

Are there better ideas? Is it possible to do an update in the database and only replace part of field?

    You could use regular expressions on the data, not my forte those expressions so I'm not going to write any code for you.

    Some of the string functions like str replace could also do the job I'm sure.

    Yes, mysql can find and replace parts of a string in a column, but that would probably be more complex than doing it in php. The one advantage you might have would be that the replacement string could be stored in the db as well. But then you could just query for it from php anyway.

      could you use?

      print "http://affiliates.art.com/get.art?T=".$TrackID."&A=".$AffiliateID Here."&L=.... ";
      

        If you post a few lines of your data download and tell what your "new line" should look like (using a line in the datafile), i can give you a simple routine to fix it.
        :-)

        ramsfield wrote:

        I am an affiliate for a some merchants. I receive a data download from via FTP. I then upload the products into MySQL. Currently I have to open the files in notepad and do a find and replace to correct the url to represent my affiliate info. This can be quite time consuming and cumbersome, considering some of these files are several hundred MBs.

        So...is it possible to change, while the page is being generated, a url. For instance, the field may have something like http://affiliates.art.com/get.art?T=[TrackID Here]&A=[AffiliateID Here]&L=.... I would like it change this url to something like http://affiliates.art.com/get.art?T=12345A=67891&L=

        Basically to replace the [TrackID Here] and [AffiliateID Here] with a numeric values that are defined in the code of the page.

        Are there better ideas? Is it possible to do an update in the database and only replace part of field?

        🙂 🙂 🙂

          Write a Reply...