I want to store affiliate url's in my database but leave a variable I can change out the affiliate id (if possible), like this:
http://www.whatever.com/buy.php?affiliate=sam (where sam would be the variable)
http://www.whatever.com/affiliates/sam/index (again, with sam being the variable)
I know I could put in certain characters there and then use preg_match to find it, and replace it, but I want to see if there is a faster/better way.
Storing php variable in database?
Moderator: General Moderators
-
jabbaonthedais
- Forum Contributor
- Posts: 127
- Joined: Wed Aug 18, 2004 12:08 pm
-
jabbaonthedais
- Forum Contributor
- Posts: 127
- Joined: Wed Aug 18, 2004 12:08 pm
I know this is totally different, but phpbb uses these brackets like {} in the template includes for variables. I am going to download and check out that code again, but I was wondering if there was a fast way to do it. Like storing the url with {affiliateid}. I will be using these records a lot, and might pull 20-50 per page, so don't want to use unnecessary functions if possible.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It's either str_replace() in PHP or the database's own string replacement function. Either way, you'll incur the transform somewhere.