SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Oct 26, 2007, 03:21 #1
Storing / exchanging URLs without a database ?
I just wrote a simple redirect script so that I could send traffic off-site using the format: domain.com/redirect.php?url=redirecting.com
Initially I just used a switch statement with half a dozen URLs where the '.com' url would be changed for the full url, like 'http://www.redirecting.com/folder/affiliateid' so I'm just simplifying URLs for the sake of keeping things easy while I build pages.
This all works fine but it's quite useful and I'd like to add a heap more links. I'd keep using the same format but I would imagine there's a more efficient way than using a switch ? What's the best way to do it without involving a database (mysql etc) ? I believe I could use a flat file database but I wouldn't know where to start.Looking for people to post on an Adult forum.
Must be cheap or willing to trade posts.
-
Oct 26, 2007, 03:41 #2
- Join Date
- Apr 2004
- Location
- germany
- Posts
- 4,324
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Make an array like 'url1' => 'redirect1', 'url2' => 'redirect2' etc and pull the addresses out of it: if(isset $array[$param]) redirect($array[$param])
-
Oct 26, 2007, 15:24 #3
I haven't used arrays, so are they the most efficient way of doing this ?
I want to be able to add maybe a few hundred links and not have anything slow down.Looking for people to post on an Adult forum.
Must be cheap or willing to trade posts.
-
Oct 26, 2007, 19:25 #4
- Join Date
- Oct 2007
- Location
- In the blogosphere
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In that case you really should be using a database
But like frog said, you could store a serialized array and open and write the file as needed. It would probably work a few hundred links but will not for a few thousand as it'd load of all the links in an array.
★ bLueFrogX's Blog - Random Ramblings of a NEET Techie ★
-
Oct 27, 2007, 00:02 #5
-
Oct 27, 2007, 07:21 #6
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A flat file database is possible, but as bluefrogx recommended, you'd be much better off using a real database. If I may ask, why are you hesitant to use one? It's really not all that complicated.
-
Oct 27, 2007, 14:49 #7
This script is more to mask affiliate links so if they change their links I only change it in one place, not dozens of places on dozens of pages. It would also be nice to throw it up on a few different domains.
If I'm going to go for a database there's tons of ad rotation style programs out there I could use.Looking for people to post on an Adult forum.
Must be cheap or willing to trade posts.
-
Oct 27, 2007, 17:07 #8
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Then why don't you? If your switch is becoming unwieldy, it might be time to switch to a database solution anyways, whether you write it yourself or not.
Bookmarks