Jump to content

[SOLVED] Why doesn't $hits display?


3raser

Recommended Posts

<html>
<head><title>Dooms day vote - What do you think will happen?...</title>
<style>

body {
     text-align:center;
     font-family:arial;
}

h1 {
   color:red;
}
</style>

<body>

<h1>Dooms day vote</h1>

<?php

$vote = $_GET['vote'];
$ip = $_SERVER['REMOTE_ADDR'];

//prosses of getting the numbers for users

        $construct = "SELECT * FROM votes WHERE ip='$ip'";
        $run = mysql_query($construct);

        $foundnum = (mysql_num_rows($run));

$count_my_page1 = ("yescount.txt");
$hits1 = file($count_my_page1);
$fp1 = fopen($count_my_page1 , "w");
fputs($fp1 , "$hits[0]");
fclose($fp1);

$count_my_page = ("nocount.txt");
$hits = file($count_my_page);
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);

if ($foundnum ==1)
   die("Already voted! Stats: <b>". $hits[0] ."</b> voted yes! <b>". $hits1[0] ."</b> voted no!");

if (!$vote) 
   die("<a href='index.php?vote=yes'>It's going to happen! RUN!</a> || <a href='index.php?vote=no'>It's not going to happen! DUH!</a>");

if ($vote =="yes") {
  
$count_my_page1 = ("yescount.txt");
$hits1 = file($count_my_page1);
$hits1[0] ++;
$fp1 = fopen($count_my_page1 , "w");
fputs($fp1, "$hits1[0]");
fclose($fp1);
echo "A total of ".$hits1[0]." people have voted it's going to happen!";

$write_their_vote = mysql_query("INSERT INTO votes VALUES ('$ip')") or die(mysql_error());
   }

if ($vote =="no") {
   $count_my_page = ("nocount.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo "A total of ".$hits[0]." people have voted it's not going to happen!";

$write_their_vote = mysql_query("INSERT INTO votes VALUES ('$ip')") or die(mysql_error());
   }

?>
</body>
</html>		

Link to comment
https://forums.phpfreaks.com/topic/181667-solved-why-doesnt-hits-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.