I am taking a database class and programming for the first time. Apparently, I stink. I have been grappling with this beginner code for a week and am about to lose my mind. I would (much!) appreciate any guidance. I am supposed to be coding a basic html voting form that counts results and displays them. After a variety of work-arounds, I am finally getting close but getting a ‘permissions’ error and I can’t figure out why, since I changed the file permissions on the text files to ‘w’… Ugh. Thanks for any help.
[code]
Vote Here! body {background-color:#736D62;} h1 {background-color:#423B31; color:#D8D7D4; font-family:arial; padding:6px;} h2 {color:#0B0803; font-style:italic;} IMG.displayed { display: absolute; width:100%; margin-top:20px; margin-left: auto; margin-right: auto; border-width:4px; border-style:solid; border-color:#D8D7D4;}Vote Here!
You have been to a variety of home improvement stores this summer. Please take time to vote on your favorite home-away-from-home!
Select Your Favorite Home Improvement Store
Home Depot Lowe's TreeHouse Breed & Company[/code]
[code]
Vote Here! body {background-color:#736D62;} h1 {background-color:#423B31; color:#D8D7D4; font-family:arial; padding:6px;} h2 {color:#0B0803; font-style:italic;} IMG.displayed { display: absolute; width:100%; margin-top:20px; margin-left: auto; margin-right: auto; border-width:4px; border-style:solid; border-color:#D8D7D4;}Voting Results
[php] <?php//Assign a variable ($vote) to the selected vote
$vote = $_GET[‘vote’];
//Route each vote to each of the four text files
if ($vote == ‘hd’) {
$file=‘hd.txt’;
}
else if ($vote == ‘lowes’) {
$file=‘lowes.txt’;
}
else if ($vote == ‘th’) {
$file=‘th.txt’;
}
else if ($vote == ‘bc’) {
$file=‘bc.txt’;
}
$filearray = file($file);
$count = $filearray[0];
$count = $count + 1;
file_put_contents($file, $count);
//Assign a variable to count the number in each array
$numberofhdvotes = file_get_contents(“hd.txt”);
$numberoflowesvotes = file_get_contents(“lowes.txt”);
$numberofthvotes = file_get_contents(“th.txt”);
$numberofbcvotes = file_get_contents(“bc.txt”);
echo “
The number of Home Depot votes is $numberofhdvotes.
”;echo “
The number of Lowe’s votes is $numberoflowesvotes.
”;echo “
The number of Treehouse votes is $numberofthvotes.
”;echo “
The number of Breed & Co votes is $numberofbcvotes.
”;?>
[/php]