Code: Select all
Parse error: syntax error, unexpected T_ELSE in G:\Apps\XAMPP\xampplite\htdocs\matches-two\outcome.php on line 47Code: Select all
<?php
session_start();
if (isset ($_SESSION['total']))
{
$total=$_SESSION['total'];
}
else
{
$_SESSION['total']=21;
$total=$_SESSION['total'];
$playerwin = "0";
}
?>
<?php
if ( $playerwin == "1" ) {
echo "What are you doing? You won... Go away";
exit;
}
else
{
echo "Matches remaining: $total";
}
?>
<html>
<body>
<br>
<a href='pickup.php'>PLAY!</a>
</body>
</html>Code: Select all
<?php
session_start();
if (isset ($_SESSION['total']))
{
$total=$_SESSION['total'];
}
else
{
echo "A disaster has occured, run away, save yourself!";
exit;
}
include 'computer.php';
$computerminus = $total - $computer;
if ($playerwin == "1") {
echo "YOU WIN!";
unset ($_SESSION['total']);
$_SESSION['total']=21;
echo "<a href='index.php'>Replay?</a>";
exit;
}
unset ($_SESSION['total']);
$_SESSION['total']=$computerminus;
$total=$_SESSION['total'];
echo " Computer took:'$computer' <br>";
echo " Remaining matches:'$computerminus' ";
?>
<form action="outcome.php" method="post">
Enter a number between 1 and 3: <input type="text" name="playerinput" size="1" />
<input type="submit" value="submit" name="submit" />
</form>Code: Select all
<?php
if (isset ($_SESSION['total']))
{
$total=$_SESSION['total'];
}
if ($total == "3") {
$comptake = "2";
}
if ($total =="2") {
$comptake = "1";
}
if ($total == "1") {
$playerwin = "1";
exit;
}
else
{
$comptake = array("1" , "2" , "3");
$comptake = rand (1,3);
}
$computer = $comptake;
echo "$comptake";
?> Code: Select all
<?php
session_start();
if (isset ($_SESSION['total']))
{
$total=$_SESSION['total'];
}
else
{
echo "A disaster has occured, run away, save yourself!";
exit;
}
$player=$_POST['playerinput'];
$player=strip_tags($player);
$playertake = $total - $player ;
if ($total > "1")
{
if (is_numeric ($player))
{
if ($player > "3")
{
echo "You picked up to many matches!<br>";
echo "<a href='pickup.php'>Return</a>";
exit;
}
if ($player < "1")
{
echo "You picked up to few matches!<br>";
echo "<a href='pickup.php'>Return</a>";
exit;
}
echo "Matches remaining: $playertake <br> ";
echo "<a href='pickup.php'>Return</a>";
unset ($_SESSION['total']);
$_SESSION['total']=$playertake;
$total=$_SESSION['total'];
}
else
{
echo "You used letters.</a>";
echo "<a href='pickup.php'>Return</a>";
exit;
}
else
{
echo " You lose!";
unset ($_SESSION['total']);
$_SESSION['total']=21;
echo "<a href='index.php'>Replay?</a>";
exit;
}
}
?>