Error PHP Variable autoincrement [closed]

0

Good morning,

I have a problem with the following code , it gives me error on line 47, specifically in:

$arr_vote[$reply]++;

Any idea of the reason? The error message of the page is as follows:

  

Parse error: syntax error, unexpected '$ arr_vote' (T_VARIABLE) in   D: \ XAMPP \ htdocs \ php5 \ poll \ vote.php on line 59.

The code:

<!DOCTYPE HTML PUBLIC "-//W·C//DTD HTML 4.01 Transitional//EN">
<?php
setcookie("check", 1);
if (isset($_POST["submit"])) {
    setcookie("voted", 1);
}
?>

<html>
<!--Formulario / Encuesta web-->
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859">
<title>Encuesta</title>
</head>

<body>

<center>
<h1>Encuesta</h1><br>
<h3>¿Que opinas?</h3>
</center><br>

<p>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
    <!--Formulario: tres opciones-->
    <input type="radio" name="reply" value="0">
    Bien<br>
    <input type="radio" name="reply" value="1">
    Regular<br>
    <input type="radio" name="reply" value="2">
    Mal<br><br>
    <?php
        if (empty($_POST["submit"]) && empty($_COOKIE["voted"])) {
            // Solo aparece el botón de submit si el formulario no se ha   enviado y el usuario no ha votado todavia.
    ?>
    <!--Aparece el botón de enviar "submit" si se cumple la condición if anterior-->
    <input name="submit" type="submit" value="Vota!">
    <?php
        } else {
            echo "<b>Gracias por tu voto</b>\n";
            if (isset($_POST["reply"]) && isset($_COOKIE["check"]) && empty($_COOKIE["voted"])) {
                $file = "results.txt";
                $fp = fopen($file, "r+");
                $vote = fread($fp, filesize($file));
                $arr_vote = explode(",", $vote); 
                $reply = $_POST["reply"]
                $arr_vote[$reply]++;
                $vote = implode(",", $arr_vote);
                rewind($fp);
                fputs($fp, $vote);
                fclose($fp);
            }
        }       
    ?>
</form>
</p><br>

<center>

<p>
    <!--Hacemos ver un enlace que nos manda a los resultados de la encuesta-->
    [ <a href="results.php" target="_blank">Ver resultados de la encuesta</a> ]
</p>

</center><br>

<center>

<p>
<!--Contador de Visitas-->
Cantidad de visitas:
    <b><?php
        $v1 = fopen("contador_vote.txt", "r+");
        $counter = fgets($v1, 7);
        echo $counter;
        $counter++;
        rewind($v1);
        fputs($v1, $counter);
        fclose($v1);
    ?></b>
</p>

</center><br>

</body>

Greetings

    
asked by fertry 08.06.2017 в 15:52
source

1 answer

1

You are missing a semicolon ";"

if (isset($_POST["reply"]) && isset($_COOKIE["check"]) && empty($_COOKIE["voted"])) {
                $file = "results.txt";
                $fp = fopen($file, "r+");
                $vote = fread($fp, filesize($file));
                $arr_vote = explode(",", $vote); 
                $reply = $_POST["reply"]; <--------------- AQUI
                $arr_vote[$reply]++;
                $vote = implode(",", $arr_vote);
                rewind($fp);
                fputs($fp, $vote);
                fclose($fp);
            }
    
answered by 08.06.2017 / 16:02
source