Page 1 of 1
[SOLVED] Link System
Posted: Fri Mar 25, 2005 5:57 pm
by Sphen001
Hi,
I'm trying to create a link type system which counts the number of clicks a certain link has. Right now, the script updates the count in the DB, and then redirects to the URL via a META redirect. Is there a better way? I've tried it by using header redirects, but get header_already_sent messages.
Thanks for your help
Sphen001
Posted: Fri Mar 25, 2005 6:00 pm
by Joe
Code: Select all
location.href='http://www.yousite.com'
(Javascript)
The database is fine for keeping track of clicks.
Posted: Fri Mar 25, 2005 6:05 pm
by Sphen001
Hi,
Thanks a lot. That's very cool. I have one tiny problem with that. There is the problem that this system is going to be distributed, and because JavaScript can be turned off in the browser, a problem emerges. I like the idea though. If there are any more ideas, I'd love to hear them.
Thanks,
Sphen001
Posted: Fri Mar 25, 2005 7:13 pm
by feyd
you're getting header already sent messages because you have output some form of data before the header() functions get called.
Have a read:
viewtopic.php?t=1157
Posted: Fri Mar 25, 2005 8:25 pm
by Sphen001
Hi,
Sorry, I should have said that I already know why I'm getting the errors. Right now, I'm using META, and I would like to do something a bit less undetectable, but I can't think of anything that would work. I have thought about doing output buffering, but that would require a complete rewrite of my whole script. I'm keeping it in mind though. Also, I'm wondering if there's a faster way to update the database. Right now, I'm getting the count from the DB, adding one, and then updating the DB. Is there some way that I could do that a bit faster, maybe without so many queries?
Thanks,
Sphen001
Posted: Fri Mar 25, 2005 8:42 pm
by feyd
it can be done in a single query
Code: Select all
UPDATE `table` SET `field` = `field` + 1 WHERE `id` = '24'
Posted: Sat Mar 26, 2005 8:16 am
by Sphen001
Awesome!
Thanks so much
Sphen001