Jump to content

[SOLVED] I don't have a clue


decypher

Recommended Posts

fixed most errors in this program however I keep gettin the error:

 

'Parse error: syntax error, unexpected $end in C:\Program Files\Abyss Web Server\htdocs\pokerdice.php on line 223'

 

which signifies the last line of coding </html>

 

I'm totally confused and don't have a clue what this could mean...any ideas? ???

 

<html>
<head>
<title>Poker Dice<title>
<style type = "text/css">
</stlye>
</head>
<body>

<center>
<h1>Poker Dice</h1>

<form method = "POST">

<?php

$cash = $_POST['cash'];
$secondroll = $_POST['secondroll'];

// Check to see if this is first time here
if(empty($cash)){
  $cash = 100;
} // end if

rolldice();

if($secondroll == TRUE){
  print"<h2>Second Roll</h2>\n";
$secondroll = FALSE;
evaluate();
} else {
print "<h2>First roll</h2>\n";
$secondroll = TRUE;
} // end if

printstuff();

function rolldice(){ 
global $die, $secondroll, $keepit;
  print "<table border = 1><td><tr>";

for ($i = 0; $i < 5; $i++){
  if ($keepit[$i] == ""){
   $die[$i] = rand(1, 6);
} else {
  $die[$i] = $keepit[$i];
} // end if


//print out dice images
print <<<HERE
<td>
<img src ="$die[$i].jpg"
     height = 50
     width = 50<br>

HERE;

//print out a checkboz on first roll only
   if ($secondroll == FALSE) {
   print <<<HERE
<input type = "checkbox"
       name = "$keepit[$i]"
      value = $die[$i]">
</td>

  } // end if
} // end for loop

//print out submit button and end of table
print <<<HERE
</tr></tD>
<tr>
  <td colspan = "5">
  <center>
  <input type "submit"
        value "Roll again">
  </center>

</td>
</tr>
</table>

HERE;

} // end rolldice

function evaluate() {
global $die, $cash;
  //set up payoff
$payoff = o;

  //subtract some money for this roll
$cash -=2;

//count the dice
$numvals= arrays(6);
  for ($theval = 1; $theval <= 6; $theval++){
  for ($dienum = 0; $dienum < 5; $dienum++){
  if ($die[$dienum] == $theval){
   $numvals[$theval]++;
} // end if
} // end dienum for loop
} // end theval for loop

  //print out results
  // for ($i = 1; $i <= 6; $i++){
// print "$i: $numvals[$i]<br>\n";
// } end for loop

//count how many pairs, threesm fours, fives
$numpairs = 0;
$numthrees = 0;
$numfours = 0;
$numfives = 0;

for ($i = 1; $i <=6; $i++){
  switch ($numvals[$i]){
    case 2:
  $numpairs++;
    break;
    case 3:
  $numthrees++;
    break;
    case 4:
  $numfours++;
    break;
    case 5:
  $numfives++;
    break;
} // end switch
} // end for loop


//check for a pair
if ($numpairs == 1){
print "You have two pairs!<br>\n";
  $payoff = 4;
} // end if

//check for two pairs
if ($numpairs == 2){
print "You have two pairs!<br>\n";
  $payoff = 7;
} // end if

//check for a three of a kind and a full house
if ($numthrees == 1){
   if($numpairs ==1){
//three of a kind and a pair is a full house
print "You have a full house!<br>\n";
  $payoff = 15;
} else {
print "You have a three of a kind!<br>\n";
  $payoff = 12;
} // end 'pair' if
} // end 'three'if

//check for a four of a kind
if ($numfours == 1){
print "You have a four of a kind!<br>\n";
  $payoff = 25;
} // end if 
} // end if


//check for a five of a kind
if ($numfives == 1){
print "You have a five of a kind!<br>\n";
  $payoff = 30;
} // end if

//check for flushes

if (($numvals[1] == 1)
&& ($numvals[2] == 1)
&& ($numvals[3] == 1)
&& ($numvals[4] == 1)
&& ($numvals[5] == 1)){
  print "You have a flush<br>\n";
  $payoff = 20;
} // end if

if (($numvals[2] == 1)
&& ($numvals[3] == 1)
&& ($numvals[4] == 1)
&& ($numvals[5] == 1)
&& ($numvals[6] == 1)){
  print "You have a flush<br>\n";
  $payoff = 20;
} // end if

print "you bet 5<br>\n";
print "Payoff is $payoff<br>\n";
$cash += $payoff;

} // end evaluate

function printstuff(){

  global $cash, $secondroll;

print "cash: $cash\n";

//store variables in hidden fields
print <<<HERE
<input type = "hidden"
       name = "secondroll"
       value = "$secondroll">

<input type = "hidden"
       name = "cash"
       value = "$cash">

HERE;

} // end printstuff

?>

</form>
</center>
</body>
</html> 

Link to comment
https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/
Share on other sites

    <html>
    <head>
    <title>Poker Dice<title>
    </head>
    <body>
    
    <center>
    <h1>Poker Dice</h1>
    
    <form method = "POST">
    
    <?php
    
    $cash = $_POST['cash'];
    $secondroll = $_POST['secondroll'];
    
    // Check to see if this is first time here
    if (empty($cash)) $cash = 100;
    
    rolldice();
    
    if ($secondroll == TRUE) {
        print"<h2>Second Roll</h2>\n";
        $secondroll = FALSE;
        evaluate();
    } else {
        print "<h2>First roll</h2>\n";
        $secondroll = TRUE;
    }
    // end if
    
    printstuff();
    
    function rolldice()
    {
        global $die, $secondroll, $keepit;
        print "<table border = 1><td><tr>";
        
        for ($i = 0; $i < 5; $i++) {
            if ($keepit[$i] == "") {
                $die[$i] = rand(1, 6);
            } else {
                $die[$i] = $keepit[$i];
            }
            // end if
            
            
            //print out dice images
            print <<<HERE
            <td>
            <img src ="$die[$i].jpg"
            height = 50
            width = 50<br>
            
HERE;
            
            //print out a checkboz on first roll only
            if ($secondroll == FALSE) {
                print <<<HERE
                <input type = "checkbox"
                name = "$keepit[$i]"
                value = "$die[$i]">
                </td>
HERE;
                
            }
            // end if
        }
        // end for loop
        
        //print out submit button and end of table
        print <<<HERE
        </tr></tD>
        <tr>
        <td colspan = "5">
        <center>
        <input type "submit"
        value "Roll again">
        </center>
        
        </td>
        </tr>
        </table>
        
HERE;
        
    }
    // end rolldice
    
    function evaluate()
    {
        global $die, $cash;
        //set up payoff
        $payoff = o;
        
        //subtract some money for this roll
        $cash -=2;
        
        //count the dice
        $numvals= arrays(6);
        for ($theval = 1; $theval <= 6; $theval++) {
            for ($dienum = 0; $dienum < 5; $dienum++) {
                if ($die[$dienum] == $theval) {
                    $numvals[$theval]++;
                }
                // end if
            }
            // end dienum for loop
        }//*****************************************
        // end theval for loop
        
        //print out results
        // for ($i = 1; $i <= 6; $i++){
        // print "$i: $numvals[$i]<br>\n";
        // } end for loop
        
        //count how many pairs, threesm fours, fives
        $numpairs = 0;
        $numthrees = 0;
        $numfours = 0;
        $numfives = 0;
        
        for ($i = 1; $i <=6; $i++) {
            switch ($numvals[$i]) {
            case 2:
                $numpairs++;
                break;
            case 3:
                $numthrees++;
                break;
            case 4:
                $numfours++;
                break;
            case 5:
                $numfives++;
                break;
            }
            // end switch
        }
        // end for loop
        
        
        //check for a pair
        if ($numpairs == 1) {
            print "You have two pairs!<br>\n";
            $payoff = 4;
        }
        // end if
        
        //check for two pairs
        if ($numpairs == 2) {
            print "You have two pairs!<br>\n";
            $payoff = 7;
        }
        // end if
        
        //check for a three of a kind and a full house
        if ($numthrees == 1) {
            if ($numpairs ==1) {
                //three of a kind and a pair is a full house
                print "You have a full house!<br>\n";
                $payoff = 15;
            } else {
                print "You have a three of a kind!<br>\n";
                $payoff = 12;
            }
            // end 'pair' if
        }
        // end 'three'if
        
        //check for a four of a kind
        if ($numfours == 1) {
            print "You have a four of a kind!<br>\n";
            $payoff = 25;
        }
        // end if
    }//**********************************
    // end if
    
    
    //check for a five of a kind
    if ($numfives == 1) {
        print "You have a five of a kind!<br>\n";
        $payoff = 30;
    }
    // end if
    
    //check for flushes
    
    if (($numvals[1] == 1)
    && ($numvals[2] == 1)
    && ($numvals[3] == 1)
    && ($numvals[4] == 1)
    && ($numvals[5] == 1)) {
        print "You have a flush<br>\n";
        $payoff = 20;
    }
    // end if
    
    if (($numvals[2] == 1)
    && ($numvals[3] == 1)
    && ($numvals[4] == 1)
    && ($numvals[5] == 1)
    && ($numvals[6] == 1)) {
        print "You have a flush<br>\n";
        $payoff = 20;
    }
    // end if
    
    print "you bet 5<br>\n";
    print "Payoff is $payoff<br>\n";
    $cash += $payoff;
    
// end evaluate

function printstuff()
{
    
    global $cash, $secondroll;
    
    print "cash: $cash\n";
    
    //store variables in hidden fields
    print <<<HERE
    <input type = "hidden"
    name = "secondroll"
    value = "$secondroll">
    
    <input type = "hidden"
    name = "cash"
    value = "$cash">
    
HERE;
    
}
// end printstuff

?>

</form>
</center>
</body>
</html>

 

Wow, that took me a while to find the error xP I finally found it though, you had an extra bracket in there.

Yes, you need that. I already took out the one that was supposed to be gone, the code above should work for you, I tested it.

 

sorry for all the **************'s next to that bracket, I was looking for the missing one, so I was marking them all with *'s...I thought I deleted them all.

 

So try the code I gave without deleting anything and see if it works.

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.