Newbie Posted March 15, 2012 Share Posted March 15, 2012 hey all i found this 5050 game on cronus old fourm and its not working properly the person who posted hasnt been on in ages anyways it was just saying "You are trying to bet more than you have" i managed to fix that because the poster had [points] instead of [crystals] now when you type in your bet it doesnt do anything just refreshes the screen can anyone else have a look see if iam missing anything <?php include 'globals.php'; global $h,$ir; //original mod by mark mascola August 11, 2011 if(isset($_POST['match']) && is_numeric($_POST['match'])){ $q=$db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']){ echo"<br />You are trying to bet more than you have"; $h->endpage(); exit; }elseif($ir['userid'] == $r['bettor']){ echo"<br />You cannot match your own bets"; $h->endpage(); exit; }else{ $db->query("UPDATE users SET second = second - {$r['wager']} WHERE userid={$ir['userid']}"); $j=rand(1,2); if($j==1){//the winner is the original bettor $db->query("UPDATE users SET second = second + ".$win." WHERE userid = {$r['bettor']}"); event_add($r['bettor'], "You won your 50/50 bet of ".$r['wager']." points and earned ".floor($r['wager']*(1.8))." points!"); event_add($ir['userid'], "You lost your 50/50 bet of ".$r['wager']." points."); } if($j==2){//the winner is the matcher $db->query("UPDATE users SET second = second + ".$win." WHERE userid = {$ir['userid']}"); event_add($r['bettor'], "You lost your 50/50 bet of ".$r['wager']." points."); event_add($ir['userid'], "You won your 50/50 bet of ".$r['wager']." points and earned ".floor($r['wager']*(1.8))." points"); } //need to add events to both the bettor and the taker.. need to delete the bet and update players with points $db->query("DELETE FROM fifty WHERE bet_id = {$r['bet_id']}"); } } if(isset($_POST['cryatals']) && is_numeric($_POST['crystals'])){ if($_POST['cryatals'] < 10){ echo "<br />You are not betting enough"; $h->endpage(); exit; } elseif($_POST['cryatals'] > 5000){ echo "<br />You are trying to bet too much"; $h->endpage(); exit; } elseif($ir['second'] < $_POST['cryatals']){ echo "<br />You are trying to bet more than you have"; $h->endpage(); exit; } else{ $db->query("UPDATE users SET `second` = `second` - {$_POST['crystals']} where userid={$userid}"); $db->query("INSERT INTO fifty VALUES('',{$ir['userid']},{$_POST['crystals']},unix_timestamp())"); } } echo"<h2>50/50 Points Game</h2>"; echo"<p>The rules are simple.<br /> 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>"; echo"<p>The maximum bet is 5000 points but you may wager more than once.</p>"; echo "<p> <form method='post'> <input type='text' name='points' size='8' maxlength='7'> points (10-5000)<br /><br /> <input type='submit' name='bet' value='PlaceBet'> </form> </p> <h3>Awaiting Bets</h3> <p> <table width='90%'> <tr> <th><b>Mobster</b></td> <th><b>Points</b></td> <th><b>Bet Age</b></td> <th align='center'><b>Bet</b></td> </tr>"; $q = $db->query("SELECT f.*,u.username FROM fifty f LEFT JOIN users u ON f.bettor = u.userid ORDER BY bet_id ASC"); while($r = $db->fetch_row($q)) { echo"<tr>"; echo"<td>".$r['username']."</td>"; echo"<td>".$r['wager']."</td>"; echo"<td>".DateTime_Parse($r['bet_time'])."</td>"; echo "<td><form method='post'>"; echo"<input type='hidden' name='match' value='".$r['bet_id']."' /><input type='submit' value='Match Bet'></form></td>"; echo"</tr>"; } echo"</table></p>"; ?> thanks Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 15, 2012 Share Posted March 15, 2012 (edited) <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['cryatals']) && is_numeric($_POST['crystals'])){ if($_POST['cryatals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals'].' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>"; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.DateTime_Parse($r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr>'; } </table> </p>'; ?> Your issue? <input type='text' name='points' size='8' maxlength='7'> points (10-5000) Still referencing 'points' where you stated if(isset($_POST['cryatals']) && is_numeric($_POST['crystals'])){ which is looking for a field with the name 'crystals' to post value. Edited March 15, 2012 by HauntedDawg Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 15, 2012 Author Share Posted March 15, 2012 still didnt work and i dunno quite what you mean by if(isset($_POST['cryatals']) && is_numeric($_POST['crystals'])){ which is looking for a field with the name 'crystals' to post value. do you mean its looking outside of users? because thats where crystals is Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 15, 2012 Share Posted March 15, 2012 try my updated code. Quote Link to comment Share on other sites More sharing options...
Curt Posted March 15, 2012 Share Posted March 15, 2012 if(isset($_POST['cryatals']) && is_numeric($_POST['crystals'])){ lol...am I the only one noticing the spelling error ?... Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 15, 2012 Share Posted March 15, 2012 lol...am I the only one noticing the spelling error ?... My ubber n foolish mistake.. <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['crystals']) && is_numeric($_POST['crystals'])){ if($_POST['crystals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals'].' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>"; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.DateTime_Parse($r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr>'; } </table> </p>'; ?> Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 15, 2012 Author Share Posted March 15, 2012 My ubber n foolish mistake.. <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['crystals']) && is_numeric($_POST['crystals'])){ if($_POST['crystals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals'].' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>"; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.DateTime_Parse($r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr>'; } </table> </p>'; ?> nope :( just get a blank white screen when i use this Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 19, 2012 Author Share Posted March 19, 2012 seems like the host i was with was blocking errors Parse error: syntax error, unexpected ';' in /home/mobst996/public_html/fifty.php on line 33 Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 19, 2012 Share Posted March 19, 2012 That help's :P <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['crystals']) && is_numeric($_POST['crystals'])){ if($_POST['crystals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals']).' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>"; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.DateTime_Parse($r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr>'; } </table> </p>'; ?> Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 24, 2012 Author Share Posted March 24, 2012 Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/mobst996/public_html/mobs9/fifty.php on line 53 Quote Link to comment Share on other sites More sharing options...
Djkanna Posted March 25, 2012 Share Posted March 25, 2012 Line 52: </tr>"; With: </tr>'; Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 26, 2012 Author Share Posted March 26, 2012 (edited) thanks that gave a new error but i did this and it fixed it <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['crystals']) && is_numeric($_POST['crystals'])){ if($_POST['crystals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals']).' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>'; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.DateTime_Parse($r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr> </table> </p>'; } ?> but now it comes up You are trying to met more than you have. when you bet anything over 10 edit: when i try to add a bet manualy through the database i get this error aswell Fatal error: Call to undefined function datetime_parse() in /home/mobst996/public_html/mobs9/fifty.php on line 59 Edited March 26, 2012 by Newbie Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 27, 2012 Share Posted March 27, 2012 (edited) You should really try replying abit faster. <?php include_once('globals.php'); $name = 'crystals'; //Name it points or crystals? if(isset($_POST['match']) && is_numeric($_POST['match'])) { $q = $db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}"); $r = $db->fetch_row($q); $win = floor($r['wager']*(1.8)); if($ir['second'] < $r['wager']) {exit('You are trying to bet more than you have.'.$h->endpage());} if($ir['userid'] == $r['bettor']) {exit('You cannot match your own bet\s.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = `second` - '.$r['wager'].' WHERE `userid` = '.$ir['userid']); if(mt_rand(0,1)) {// either word's. if true or false $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$r['bettor']); event_add($r['bettor'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($ir['userid'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } else { $db->query('UPDATE `users` SET `second` = `second` + '.$win.' WHERE `userid` = '.$ir['userid']); event_add($ir['userid'], 'You won your 50/50 bet of '.number_format($r['wager']).' '.$name.' and earned '.floor($r['wager'] * 1.8).' '.$name.'!'); event_add($r['bettor'], 'You lost your 50/50 bet of '.number_format($r['wager']).' points.'); } $db->query('DELETE FROM `fifty` WHERE `bet_id` = '.$r['bet']); } if(isset($_POST['crystals']) && is_numeric($_POST['crystals'])){ if($_POST['crystals'] < 10) {exit('You are not betting enough.'.$h->endpage());} if($_POST['crystals'] > 5000) {exit('You are trying to bet too much.'.$h->endpage());} if($ir['second'] < $_POST['crystals']) {exit('You are trying to met more than you have.'.$h->endpage());} $db->query('UPDATE `users` SET `second` = (`second` - '.$_POST['crystals'].') WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `fifty` VALUES(NULL, '.$ir['userid'].', '.intval($_POST['crystals']).' WHERE `userid` = '.$ir['userid']); } echo '<h2>50/50 '.ucfirst($name).' Game</h2>'; echo '<p>The rules are simple. 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>'; echo '<p>The maximum bet is 5000 points but you may wager more than once.</p>'; echo '<p> <form method="post" action=""> <input type="text" name="crystals" size="8" maxlength="7" /> '.ucfirst($name).' (10-5000) <input type="submit" name="bet" value="Place Bet" /> </form> </p> <h3>Awaiting Bets</h3> <p> <table width="90%"> <tr> <th><strong>Mobster</strong></td> <th><strong>Points</strong></td> <th><strong>Bet Age</strong></td> <th align="center"><strong>Bet</strong></td> </tr>'; $q = $db->query('SELECT `f`.`wager`, `f`.`bet_time`, `f`.`bet_id`, `u`.`username` FROM `fifty` `f` LEFT JOIN `users` `u` ON `f`.`bettor` = `u`.`userid` ORDER BY `bet_id` ASC'); while($r = mysql_fetch_assoc($q)) { echo ' <tr> <td>'.$r['username'].'</td> <td>'.$r['wager'].'</td> <td>'.date('G:s', $r['bet_time']).'</td> <td><form method="post"><input type="hidden" name="match" value="'.$r['bet_id'].'" /><input type="submit" value="Match Bet"></form></td> </tr>'; } echo ' </table> </p>'; ?> I've now tested this in my XAMPP and came out with 0 error's. Edited March 27, 2012 by HauntedDawg Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 27, 2012 Author Share Posted March 27, 2012 not had much time to myself recently but i tried out your code today and it shows that the fifty.php is working fine until a user bets its not inserting the bet into the database i have looked at the op post on cronwerks forum and there is no sql for second i tried to add it manually and still no success op here http://www.cronwerks.com/forum/free-user-created-mccode-mccodes-mods/5050-game-for-redux/ this is what i used ALTER TABLE `users` ADD `second` INT( 11 ) NOT NULL DEFAULT '0' thanks Quote Link to comment Share on other sites More sharing options...
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.