I'm building a simple Yes/No poll that uses Flash to vote, PHP to update the vote counts in a text file, and then Flash again to display the current results. My problem (other than being new to PHP) is getting the PHP to tell the difference between the "yes" counts and the "no" counts when it comes to updating them.
Here's the simple text file where the counts are stored:
And here's the PHP code. I've been able to have it update one count from the text file (which is what I have below), but not two different counts.
I know it comes from having two different variables/split() functions/etc., I just can't figure out how to differentiate between the two.
Thanks in advance!
Here's the simple text file where the counts are stored:
Code:
&countYes=243&countNo=31
Code:
<?
$filename = "20091115.txt";
$fp = fopen( $filename,"r");
$Old = fread($fp, 100);
fclose( $fp );
$Old = split("=", $Old, 4);
$NewYesCount = $Old[1] + '1';
$New = "countYes=$NewYesCount";
$fp = fopen( $filename,"w+");
if (flock($fp, 2)) {
fwrite($fp, $New, 100); }
fclose( $fp );
?>
Thanks in advance!
Comment