View Full Version : PHP Counter is not working :(
PaulD
October 27th, 2003, 10:10 PM
Hi everyone
I have found this PHP Counter on the net but when applied to my Webpage it does not work.
Just wondering if anyone can take a look if they get a spare second or two.
I have attached the file dynamic_counter.zip
this is what it looks like in action on my website
http://www.****soncreativedesigns.com
as you can see the counter is not displaying :(
eyeinfinitude
October 28th, 2003, 05:07 AM
Does your host support PHP?
PaulD
October 28th, 2003, 05:24 AM
Yes it does support PHP, I have a contact form using PHP & that works ok.
Wierd :h:
eyeinfinitude
October 28th, 2003, 05:54 AM
Hmm....there aren't any instructions with that thing, but I think you might have to CHMOD the text file in order for it to work.
PaulD
October 28th, 2003, 06:08 AM
CHMOD the text file. How do I do that?
eyeinfinitude
October 28th, 2003, 06:12 AM
Some FTP programs has that feature.
PaulD
October 28th, 2003, 06:20 AM
I'm using FlashFXP FTP Program, do I have to tell the txt file to be CHMOD? What is CHMOD?
eyeinfinitude
October 28th, 2003, 06:22 AM
Yes, you'll need to do it through whichever FTP program you have if it has that feature.
CHMOD basically allows the the information in the text file to be read or written over.
EDIT: I also believe you'll need to CHMOD it 777, but I'm not sure.
PaulD
October 28th, 2003, 07:06 AM
ok I will see what I can do, thx for the info!!!!
PaulD
October 28th, 2003, 08:19 AM
Ok I managed to work out what I was doing wrong & thought I would let you know.
I needed to change the file permissions on my web server to READ,WRITE,EXECUTE.
The Chmod php file was 665 (-rw-rw-r-x) and the text file was 666 (-rw-rw-rw-).
Thanks for your help ;)
PaulD
October 28th, 2003, 11:04 AM
I was using PHP3 which I dont think the server supports, hopefully by updating the actionscript to PHP will allow the counter to function.
PaulD
October 28th, 2003, 11:09 AM
**** it did not work :( wierd
Im referencing from this tutorial
http://www.actionscript.org/tutorials/intermediate/dynamic_counter_php3/index.shtml
toshiro
October 28th, 2003, 02:21 PM
For future reference, flashfxp chmod shortcut is ctrl+o or just right click the file and select CHMOD (right clicking also shows the shortcut). Since you changed the file extension be sure to re-read the code and be sure that all referenced files are .php now and not .php3
PaulD
October 29th, 2003, 11:14 AM
Ok I have changed my PHP script to the following:
<?php $fd = fopen("counter.txt", "w");
fwrite($fd, "count=".$_GET['count']."&loaded=1");
fclose($fd); ?>
<p>Counter incremented: value is now <?php echo $_GET['count'];?>
Still does not seem to be functioning
Marz
October 29th, 2003, 12:41 PM
Some things to try out.. I use text files all the time..
First, don't you need to read what count to increment before you actually can increment it?
I'll make you a quick script that should work for ya..
Here..
<?php
$rawData = file("counter.txt");
$rawData[0] = rtrim(rawData[0]);
$numData = sprintf("%d", $rawData[0]);
$numData++;
unlink("counter.txt");
$filePointer = fopen("counter.txt", "w");
$strData = sprintf("%s", $numData);
fputs($filePointer, "$strData\r\n");
fclose($filePointer);
?>
It may look like alot for a simple counter. But this will ensure that no variable changeovers get in the way of placing a better counter in your system. It automatically updates it's numbers so it's alot easier.
I don't know why they had the GET global variable set used in your example.. That would only work everytime someone sent a form or something... Weird.
PaulD
October 29th, 2003, 12:57 PM
@ Bhuddamarz
Here is the location of the source files I am currently using.
< http://www.****soncreativedesigns.com.temp/counter.zip >
Do you suggest I change the "counter.php" scripting to the one you have specified below?
I will give it a try...
PaulD
October 29th, 2003, 01:16 PM
It still did not work even with your modified script. Thank you for trying.
I'm think that there is something wrong with this script on Frame1 of my FLA file.
if (startup eq "") {
startup = "Run Already";
loadVariables("counter.txt?" add random(2000), "/counter");
}
shouldn't the "/counter" be "/counter.php" ?
Marz
October 29th, 2003, 02:14 PM
Ohhhhh! You want this made for flash.. *lmfao*.. Oh **** man.. Hold on.. lemme get you some newer script.. *lmao*.. Sorry...
eyeinfinitude
October 29th, 2003, 02:26 PM
Paul, please excuse Marlin here, he's been smoking too much butt crack lately. :beam:
Marz
October 29th, 2003, 02:37 PM
if (startup eq "")
Exactly what does this line here do? Is this a part of the new MX 2004 or is it just wrongly written?
Ohhh NEver mind.. It's a eq... *lmao*... Actually.. Why don't you do this...
if(startup == FALSE)
{
startup = TRUE;
loadVariables("counter.txt", "_root.countTarget");
}
The countTarget should be a textfield located on your movie.. Should be in Frame 1 along with this coding. name it countTarget. On the text field, you should also change the variable setting as well.. Give it a name of : someCounter.
Also... Change around the php code I gave you.. One tiny bit and save it as this..
<?php
$rawData = file("counter.txt");
$rawData[0] = rtrim(rawData[0]);
$numData = sprintf("%d", $rawData[0]);
$numData++;
unlink("counter.txt");
$filePointer = fopen("counter.txt", "w");
$strData = sprintf("someCounter=%s", $numData);
fputs($filePointer, "$strData\r\n");
fclose($filePointer);
?>
See if that works out for you.. I'm sorry if it doesn't.. I haven't worked with loadVariables in a while :D
PaulD
October 30th, 2003, 02:13 AM
@ buddhamarz
I have not had a chance to test your method as yet but I will try shortly.
Found another example from a guy in Melbourne.
Create a FLA with a Movie Clip 1 Frame Long.
Insert the following actions:
counter = new LoadVars();
counter.onLoad = function(ok) {
if (ok) {
counter_txt.text = this.result;
} else {
counter_txt.text = "????";
}
};
counter.load("count.php");
Then make a "count_data.txt" file with saved with the number 8
The PHP is called "count.php" and has the following
<?php
$COUNT_FILE = "count_data.txt";
if (file_exists($COUNT_FILE)) {
$fp = fopen("$COUNT_FILE", "r+");
flock($fp, 1);
$count = fgets($fp, 4096);
$count += 1;
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
$message="You are visitor number $count";
echo "result=$message";
} else {
$message="Counter done did break";
echo "result=$message";
}
?>
I tried this example & managed to get the error message :)
Maybe its my computer or maybe its my server? Because every example I try does not seem to work :q:
PaulD
October 30th, 2003, 08:22 AM
I just thought I would let you guys know that there is nothing wrong with the script I just gave you.
It has come to my attention that my web host is having problems managing my PHP files. It supports PHP as proven by my contact.php file but for some reason it does not want to support my counter.php
When I get to the bottom of this I will let you guys know what has happened.
Thanks for all your help so far
PaulD
October 31st, 2003, 01:46 AM
Well I got in contact with my Web Host today.
Support Guy: "YES we do support all PHP & Server Technologies."
Me: "So what am I doing wrong if this script works on my friends server but not yours."
Support Guy: "That is out of our support capabilites, please check your script again"
Me: "Thanks for nothing"
__________________________________________________ _
So here is all my files that I am using with file attributes 666...
http://www.****soncreativedesigns.com/Counter.zip
Here is the result I get when I upload these files to my server...
http://www.****soncreativedesigns.com/counter.swf
PaulD
October 31st, 2003, 03:16 AM
Well I solved the problem myself. I deleted all my files uploaded them again, adjusted the attributes & it worked.
Prob was my fault because I had the same files in the cgi-bin. Once I took them out the PHP counter worked.
Im sure my Host could have told me that if they weren't total idiots. Cheap prices, bad support.
Thanks to everyone who helped me solve this problem.
You can view the workable PHP counter at
http://www.****soncreativedesigns.com/counter.swf
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.