Page 1 of 1

Storing php variable in database?

Posted: Thu Aug 24, 2006 12:41 pm
by jabbaonthedais
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.

Posted: Thu Aug 24, 2006 12:45 pm
by feyd

Posted: Thu Aug 24, 2006 1:28 pm
by jabbaonthedais
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.

Posted: Thu Aug 24, 2006 3:19 pm
by feyd
It's either str_replace() in PHP or the database's own string replacement function. Either way, you'll incur the transform somewhere.