PHP Counter is not working :(

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.dicksoncreativedesigns.com

as you can see the counter is not displaying :frowning:

Does your host support PHP?

Yes it does support PHP, I have a contact form using PHP & that works ok.

Wierd :h:

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.

CHMOD the text file. How do I do that?

Some FTP programs has that feature.

I’m using FlashFXP FTP Program, do I have to tell the txt file to be CHMOD? What is CHMOD?

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.

ok I will see what I can do, thx for the info!!!

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 :wink:

I was using PHP3 which I dont think the server supports, hopefully by updating the actionscript to PHP will allow the counter to function.

**** it did not work :frowning: wierd

Im referencing from this tutorial

http://www.actionscript.org/tutorials/intermediate/dynamic_counter_php3/index.shtml

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

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

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
");
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.

@ Bhuddamarz

Here is the location of the source files I am currently using.

< http://www.dicksoncreativedesigns.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…

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.

[AS]
if (startup eq “”) {
startup = “Run Already”;
loadVariables(“counter.txt?” add random(2000), “/counter”);
}
[/AS]

shouldn’t the “/counter” be “/counter.php” ?

Ohhhhh! You want this made for flash… lmfao… Oh **** man… Hold on… lemme get you some newer script… lmao… Sorry…

Paul, please excuse Marlin here, he’s been smoking too much butt crack lately. :beam:

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
");
 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 :smiley: