Storing php variable in database?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Storing php variable in database?

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply