decypher Posted July 21, 2007 Share Posted July 21, 2007 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 More sharing options...
L Posted July 21, 2007 Share Posted July 21, 2007 u forgot to add an } to function rolldice Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303823 Share on other sites More sharing options...
decypher Posted July 21, 2007 Author Share Posted July 21, 2007 I have :S Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303826 Share on other sites More sharing options...
pocobueno1388 Posted July 21, 2007 Share Posted July 21, 2007 <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. Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303829 Share on other sites More sharing options...
decypher Posted July 21, 2007 Author Share Posted July 21, 2007 }//***************************************** // end theval for loop wouldn't I need that? and for the one at four of a kind I deleted that extra one but problem still there :S but thnx for that error Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303834 Share on other sites More sharing options...
pocobueno1388 Posted July 21, 2007 Share Posted July 21, 2007 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. Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303890 Share on other sites More sharing options...
decypher Posted July 21, 2007 Author Share Posted July 21, 2007 yeh its working...well showing up now...thnx Link to comment https://forums.phpfreaks.com/topic/61050-solved-i-dont-have-a-clue/#findComment-303992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.