Wisconsin_fireworks Posted April 28, 2010 Share Posted April 28, 2010 Hello, I am new to PHP I typically work with .NET I am trying to get this script to work that records an IP address and the number of times a user has clicked on a link to a .txt file, while expiring after a certain number of clicks (in this case, 3). This script will record the first link click and IP address, but from there it doesn't log the additional attempts. I would be grateful if some PHP savvy person can quickly look over this script and point out any obvious issues. One line in particular i am questioning is the '&' in: if (do_readfile_string(&$clicks,$filename) Thanks ahead. I zipped the 2 files and attached. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/ Share on other sites More sharing options...
premiso Posted April 28, 2010 Share Posted April 28, 2010 The & is generally used for passing as reference, but afaik, it needs to be in the funciton declaration. Not the function call. It works either way. So it is just being passed by reference (meaning that variable will contain whatever the end result was inside the function or a reference to it anyhow) Quote Link to comment https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/#findComment-1050186 Share on other sites More sharing options...
greatstar00 Posted April 28, 2010 Share Posted April 28, 2010 if (do_readfile_string(&$clicks,$filename) the & means pass value by reference if you change the $clicks in the function, the value that it gets from, will change without &, if you change the value in the function, the value that it gets from will NOT change Quote Link to comment https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/#findComment-1050188 Share on other sites More sharing options...
Wisconsin_fireworks Posted April 28, 2010 Author Share Posted April 28, 2010 ok that makes sense, thanks for the input . Does anyone know what could be wrong with this script? It seems it is not incrementing the click count. When I manually change the click value in the .txt file to say, 3, it gets overwritten with 1 after the link is clicked. Quote Link to comment https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/#findComment-1050216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.