Jump to content

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/200088-click-based-expiration-link/
Share on other sites

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)

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

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.  :confused:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.