syntax error, hoe oplossen?

Gestart doorBoriss7 reacties31 weergaven

8 berichten · pagina 1 van 1

Boriss

Lid · Topicstarter

Berichten
551
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,
Ik ben bezig met PHP leren ( sinds kort )
En ik heb nu deze code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]posted[/COLOR][COLOR= #007700]]))
([/COLOR]
[COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]guess[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$number[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700])
     ([/COLOR]
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1> Te hoog nummer... Het nummer is $number</h1><br/>"[/COLOR][COLOR= #007700];[/COLOR]
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again;"[/COLOR][COLOR= #007700];
          )[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700])
        ([/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Te laag nummer, het nummer is: $number</h1>"[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again"[/COLOR][COLOR= #007700];
            )[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]([/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]<[/COLOR]h1[COLOR= #007700]>[/COLOR]Je hebt gewonnen[COLOR= #007700]!<[/COLOR]/h1[COLOR= #007700]>


)[/COLOR]


?>


Nu krijg ik alleen de error: Parse error: syntax error, unexpected ; in /home/borisss/domains/borisss.s3.one2xs.com/public_html/index.php on line 5

alleen volgens mij hoort die ; gewoon achter [guess]

Snapt iemand wat de fout is?

Mvg, Boris
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Je gEbruikt ( verkeerd op bijna iedere regel.

Je moet { en } gebruiken bij ifs enzo

If(){

} else {

}
0
Boriss

Lid · Topicstarter

Berichten
551
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sevvlor schreef:
Je gEbruikt ( verkeerd op bijna iedere regel.

Je moet { en } gebruiken bij ifs enzo
If(){

} else {

}


Oke, Bedankt!smile
0
Berichten
1.871
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Probeer het eens zo:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]posted[/COLOR][COLOR= #007700]]))
{[/COLOR]
[COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]guess[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$number[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700])
     {[/COLOR]
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1> Te hoog nummer... Het nummer is $number</h1><br/>"[/COLOR][COLOR= #007700];[/COLOR]
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again;"[/COLOR][COLOR= #007700];
      }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700])
        {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Te laag nummer, het nummer is: $number</h1>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again"[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Je hebt gewonnen!</h1>"[/COLOR][COLOR= #007700];
        }

}[/COLOR]
?>
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]

    [COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]guess[/COLOR][COLOR= #007700]];[/COLOR]
    [COLOR= #0000BB]$number[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1> Te hoog nummer... Het nummer is $number</h1><br/>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again;"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user_guess[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$number[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Te laag nummer, het nummer is: $number</h1>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"please try again"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Je hebt gewonnen!</h1>"[/COLOR][COLOR= #007700];
    }

}[/COLOR]
?>


Uitgelijnd + betere manier om te checken of een formulier verstuurd is
0
Boriss

Lid · Topicstarter

Berichten
551
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt jongens!
0
Jef

Lid

Berichten
2.682
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
De laatste echo:

echo "<h1>Je hebt gewonnen!</h1>";
0
Boriss

Lid · Topicstarter

Berichten
551
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Slotje aub
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren