CoRnNuB Posted June 6, 2012 Posted June 6, 2012 (edited) if ( !defined($_CONFIG['define_code']) ) { echo 'This file cannot be accessed directly.'; exit; } echo '<center> <h3>High/Low</h3> </center>'; // Below = The Monk's Code // $POST['bet'] = isset($_POST['bet']) && is_numeric($_POST['bet']) ? abs((int) $_POST['bet']) : false; $POST['oldnum'] = isset($_POST['oldnum']) && is_numeric($_POST['oldnum']) ? abs((int) $_POST['oldnum']) : false; $_POST['choice'] = mysql_real_escape_string(strip_tags($_POST['choice'])); if ($_POST['bet'] && !$_POST['choice']) // Player entered bet but hasn't chosen high/low yet { if (!in_array($_POST['bet'], array('500', '1000', '5000', '10000'))) { echo 'The bet you selected is not available'; } $bet =$_POST['bet']; if($bet > $ir['money']) { echo '<center>Not enough money!</center>'; exit; } $num = number_format(rand(1,10)); echo '<center>The number is '.$num.'. Will the next number be higher or lower than '.$num.'? <table> <tr> <td> <form method="post"> <input type="hidden" value="'.$num.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="high" name="choice"> <input type="submit" value="Higher"> </form> </td> <td> <form method="post"> <input type="hidden" value="'.$num.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="low" name="choice"> <input type="submit" value="Lower"> </form> </td> </tr> </table> </center>'; } else if ($_POST['choice'] && $_POST['oldnum'] && $_POST['bet']) // Player chose high/low { $newnum = number_format(rand(1,10)); $oldnum = $_POST['oldnum']; $guess = $_POST['choice']; $bet = $_POST['bet']; if($newnum < $oldnum) { $lala = 'low'; } else if($newnum > $oldnum) { $lala = 'high'; } else if($newnum === $oldnum) { $lala = $guess; } if($lala !== $guess) { $result = 2; } else if($lala === $guess) { $result = 1; } if(!$result) { die("Error!"); } // No result was generated $db->query("UPDATE `users` SET `money`=`money`-".$bet." WHERE (`userid`=".$userid.")"); // Take away bet if($result === 1) // Player won { $prize=$bet * 2; // Prize money for winning echo '<center>Congratulations! You won your bet of \$'.$bet.' '; $db->query("UPDATE `users` SET `money`=`money`+".$prize." WHERE (`userid`=".$userid.")"); echo 'You guessed '.$guess.', the previous number was '.number_format($oldnum).' and the new number was '.number_format($newnum).'. Is the next number going to be higher or lower than '.number_format($newnum).'? <table> <tr> <td> <form method="post"> <input type="hidden" value="'.$newnum.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="high" name="choice"> <input type="submit" value="Higher"> </form> </td> <td> <form method="post"> <input type="hidden" value="'.$newnum.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="low" name="choice"> <input type="submit" value="Lower"> </form> </td> </tr> </table> </center>'; } else if($result === 2) // Player lost { echo '<center>Sorry you lost your bet of \$'.number_format($bet).' You guessed '.$guess.', the previous number was '.number_format($oldnum).' and the new number was '.number_format($newnum).'. Is the next number going to be higher or lower than '.number_format($newnum).'? <table> <tr> <td> <form method="post"> <input type="hidden" value="'.$newnum.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="high" name="choice"> <input type="submit" value="Higher"> </form> </td> <td> <form method="post"> <input type="hidden" value="'.$newnum.'" name="oldnum"> <input type="hidden" value="'.$bet.'" name="bet"> <input type="hidden" value="low" name="choice"> <input type="submit" value="Lower"> </form> </td> </tr> </table> </center>'; } } else { // Default display echo '<center>Welcome to the High/Low casino! <form action="highlow.php" method="post"> Select your bet: <select type="dropdown" name="bet"> <option value="500">$500</option> <option value="1000">$1000</option> <option value="5000">$5000</option> <option value="10000">$10000</option> </select> <input type="submit" value="Start Game!"> </form> </center>'; } // End Of The Monk's Code // ?> heres a code i tried converting from v2 to redux and it dosnt seem to work ive been following the convertion guid but it aint working and to finish it off i add this in to explore echo '<a href="'.gen_url('highlow',true).'">High Low</a>'; any help would be much appritiated Edited June 6, 2012 by Djkanna Code Tags. Quote
CoRnNuB Posted June 6, 2012 Author Posted June 6, 2012 sorry i didnt put them in them tags couldnt find out how Quote
rulerofzu Posted June 6, 2012 Posted June 6, 2012 Ok change $ir['money'] to $ir['main'] Also change the form action from <form action="highlow.php" method="post"> to <form action="'.gen_url('highlow',true).'" method="post"> upload to Mods/ edit the main index file adding the mod to the list of allowed files. 'highlow' => 'Mods/highlow.php' You was nearly there..just over looked a few things. Quote
Djkanna Posted June 6, 2012 Posted June 6, 2012 I've put in in code tags for you. [.PHP][/.PHP] [.CODE][/.CODE] [.HTML][/.HTML] So on and so forth, are code tags (without the period in between). :) Quote
Lithium Posted June 6, 2012 Posted June 6, 2012 DJK is sooo neat and tidy and helpful :D It's his female side coming to top! :P Quote
Djkanna Posted June 7, 2012 Posted June 7, 2012 It's his female side coming to top! :P Either that, or I don't want to make my eyesight even worse by attempting to read it, unformatted. :rolleyes: Quote
CoRnNuB Posted June 7, 2012 Author Posted June 7, 2012 High/Low '; // Below = The Monk's Code // $POST['bet'] = isset($_POST['bet']) && is_numeric($_POST['bet']) ? abs((int) $_POST['bet']) : false; $POST['oldnum'] = isset($_POST['oldnum']) && is_numeric($_POST['oldnum']) ? abs((int) $_POST['oldnum']) : false; $_POST['choice'] = mysql_real_escape_string(strip_tags($_POST['choice'])); if ($_POST['bet'] && !$_POST['choice']) // Player entered bet but hasn't chosen high/low yet { if (!in_array($_POST['bet'], array('500', '1000', '5000', '10000'))) { echo 'The bet you selected is not available'; } $bet =$_POST['bet']; if($bet > $ir['main']) { echo ' Not enough money! '; exit; } $num = number_format(rand(1,10)); echo ' The number is '.$num.'. Will the next number be higher or lower than '.$num.'? '; } else if ($_POST['choice'] && $_POST['oldnum'] && $_POST['bet']) // Player chose high/low { $newnum = number_format(rand(1,10)); $oldnum = $_POST['oldnum']; $guess = $_POST['choice']; $bet = $_POST['bet']; if($newnum < $oldnum) { $lala = 'low'; } else if($newnum > $oldnum) { $lala = 'high'; } else if($newnum === $oldnum) { $lala = $guess; } if($lala !== $guess) { $result = 2; } else if($lala === $guess) { $result = 1; } if(!$result) { die("Error!"); } // No result was generated $db->query("UPDATE `users` SET `money`=`money`-".$bet." WHERE (`userid`=".$userid.")"); // Take away bet if($result === 1) // Player won { $prize=$bet * 2; // Prize money for winning echo ' Congratulations! You won your bet of \$'.$bet.' '; $db->query("UPDATE `users` SET `money`=`money`+".$prize." WHERE (`userid`=".$userid.")"); echo 'You guessed '.$guess.', the previous number was '.number_format($oldnum).' and the new number was '.number_format($newnum).'. Is the next number going to be higher or lower than '.number_format($newnum).'? '; } else if($result === 2) // Player lost { echo ' Sorry you lost your bet of \$'.number_format($bet).' You guessed '.$guess.', the previous number was '.number_format($oldnum).' and the new number was '.number_format($newnum).'. Is the next number going to be higher or lower than '.number_format($newnum).'? '; } } else { // Default display echo ' Welcome to the High/Low casino! i now get this after following the instructions any one able to help again Quote
rulerofzu Posted June 7, 2012 Posted June 7, 2012 Not really sure what your getting as If you made the changes as I stated it works fine. Tested on my redux installation. Quote
CoRnNuB Posted June 7, 2012 Author Posted June 7, 2012 my last post is all the stuff that comes up when i click on my highlow so there must be something wrong with the code or ive done something wrong Quote
rulerofzu Posted June 7, 2012 Posted June 7, 2012 Your seeing the code itself? Make sure the file begins with <?php Quote
CoRnNuB Posted June 7, 2012 Author Posted June 7, 2012 by files do you mean on my cpanel make sure i name them <?php.highlow.php Quote
rulerofzu Posted June 7, 2012 Posted June 7, 2012 No in the actual code itself. It would look like your displaying the actual code which means there is no starting tag to specify that it is a php file. php files start with <?php Quote
CoRnNuB Posted June 7, 2012 Author Posted June 7, 2012 hhey ok thanks thats done now but now when i bet and click higher or lower it says The website cannot display the page HTTP 500 Most likely causes: •The website is under maintenance. •The website has a programming error. Quote
rulerofzu Posted June 7, 2012 Posted June 7, 2012 Forgot to mention change all references to money in the queries to main Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.