This would actually belong in the snippets forum.
There is too much work happening in here. The code is replicated for both the cookie and non cookied approaches. This can be factored down to this:
I didn't do anything to trap errors or change the file handling.
I would go a completely different way and use the GD to overlay the images together and kick out a script that is served as an image. The pro is that you have one image, the con is that it takes more work to do.
This would actually belong in the snippets forum.
There is too much work happening in here. The code is replicated for both the cookie and non cookied approaches. This can be factored down to this:
I didn't do anything to trap errors or change the file handling.
I would go a completely different way and use the GD to overlay the images together and kick out a script that is served as an image. The pro is that you have one image, the con is that it takes more work to do.
Oh, here is a error
print '<img src="../IMG/' . $sTxt[$i] . '.bmp' />";
use
echo "<img src='../IMG/$sTxt[$i].bmp' />";
print is outdated!
And you got the part with isset because the cookie will be inexistent or = to 1
so it will never be equal to 2 or 3 or 0 no it will be equal to "" not set but != 1
Oh, here is a error
print '<img src="../IMG/' . $sTxt[$i] . '.bmp' />";
use
echo "<img src='../IMG/$sTxt[$i].bmp' />";
print is outdated!
print will never be deprecated as its linked to the core C printf. Since it is a language construct, it would be a tremendous overhaul to remove it. And we know that's not going anywhere. Though there is an error, I have the ending ' and " in the wrong order there, that should have been:
And you got the part with isset because the cookie will be inexistent or = to 1
so it will never be equal to 2 or 3 or 0 no it will be equal to "" not set but != 1
I haven't a clue what you are talking about here. I added this:
as my impression of what the intent was is to only count up if there is no cookie currently set.
Oh wait, I see. That is backwards, I originally wrote it thinking you were only counting if countplus was available, but realized that it was the other way around. That should be:
PHP Code:
if (!isset($_COOKIE['countplus']) || $_COOKIE['countplus'] != 1)
This way if there is no cookie OR if there is a cookie and its value is not 1, that it will increment the counter and set the cookie.
Edit:
I should probably put the end in. I'd expect that this will work, but with most of what I do it is untested:
print will never be deprecated as its linked to the core C printf. Since it is a language construct, it would be a tremendous overhaul to remove it. And we know that's not going anywhere. Though there is an error, I have the ending ' and " in the wrong order there, that should have been:
as my impression of what the intent was is to only count up if there is no cookie currently set.
Oh wait, I see. That is backwards, I originally wrote it thinking you were only counting if countplus was available, but realized that it was the other way around. That should be:
PHP Code:
if (!isset($_COOKIE['countplus']) || $_COOKIE['countplus'] != 1)
This way if there is no cookie OR if there is a cookie and its value is not 1, that it will increment the counter and set the cookie.
Edit:
I should probably put the end in. I'd expect that this will work, but with most of what I do it is untested: