IsaacP Posted December 1, 2011 Share Posted December 1, 2011 my streets gives me an error with this query and won't put the person in jail else if ($step['reward_type'] == 'jail') { $db->query("UPDATE `users` SET `jail` = '{$str}', `jailreason ='{$step['reason']}' WHERE `userid` = $userid"); Quote Link to comment Share on other sites More sharing options...
IsaacP Posted December 1, 2011 Author Share Posted December 1, 2011 that wasn't the error though, it's still not working Quote Link to comment Share on other sites More sharing options...
mixmaster Posted December 1, 2011 Share Posted December 1, 2011 that wasn't the error though, it's still not working Have you put $db with the global ? Quote Link to comment Share on other sites More sharing options...
gurpreet Posted December 1, 2011 Share Posted December 1, 2011 Also post up the error, it could be a number of things. Quote Link to comment Share on other sites More sharing options...
IsaacP Posted December 1, 2011 Author Share Posted December 1, 2011 (edited) this is the full code I'm using <?php /* EXPLORE THE STREETS CREATED BY: Lithium ~ 03/01/2010 UPDATED BY: Curt ~ 08/03/2011 This feature is 100% free. Enjoy. */ include(DIRNAME(__FILE__) ."/globals.php"); ?> <table cellpadding="4" style="width: 415px; margin-top: 20px;" align="center"> <tr> <td style="background-image: url('images/gradbg.gif'); background-repeat: no-repeat;"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="401" style="background-image: url('images/newsbarhead.gif');" colspan="2" height="20" align="center"> <span class="title">Explore the Streets</span> </td> </tr> <tr> <td colspan="2" class="newspost"> <?php if(!$ir['street_turns']) { echo "You can't explore anymore today!"; $h->endpage(); exit; } if($ir['hospital']) { echo "You can't explore while injured."; $h->endpage(); exit; } if($ir['jail']) { echo"You can't explore while in jail."; $h->endpage(); exit; } $l = $db->query("SELECT * FROM `streets` WHERE (`location` = '{$ir['location']}' OR `location` = '0') ORDER BY RAND() LIMIT 1"); if($_GET['step'] == 'explore') { $db->query("UPDATE `users` SET `street_turns` = `street_turns` - '1' WHERE `userid` = $userid"); $ir['street_turns']-=1; if($db->num_rows($l)) { $step = mysql_fetch_assoc($l); $str = $step['reward']; @eval("\$str = $str;"); if ($step['reward_type'] == 'hospital') { $db->query("UPDATE `users` SET `hp` = '1', `hospital` = '{$str}', `hospreason` = '{$step['reason']}' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'jail') { $db->query("UPDATE `users` SET `jail` = '{$str}', `jailreason` ='{$step['reason']}' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'item') { item_add($userid, $str, 1); } else if ($step['reward_type'] == 'robbed') { if ($ir['money']<$str) { $str=$ir['money']; } rand(5,20)*$ir['level']; $db->query("UPDATE `users` SET `money` = `money` - '$str' WHERE `userid` = $userid"); if ($ir['crystals']<$str) { $str=$ir['crystals']; } rand(5,20)*$ir['level']; $db->query("UPDATE `users` SET `crystals` = `crystals` - '$str' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'nothing') {} else { $db->query("UPDATE `users` SET `".$step['reward_type']."` = `".$step['reward_type']."` + '$str' WHERE `userid` = $userid"); } $what = array('{money}','{crystals}','{hospital}','{jail}' ,'{nothing}','{item}','{robbed}','{exp}'); $for = is_numeric($str) ? number_format($str) : $str; echo str_replace($what, $for, stripslashes(htmlspecialchars($step['text']))); } ?> <a href="streets.php?step=explore">Continue Exploring</a> <a href="index.php">Back Home</a> You have <?php echo $ir['street_turns']; ?> turns left. <?php } else { ?> <a href="streets.php?step=explore">Explore The City</a> You have <?php echo $ir['street_turns']; ?> turns left. <?php } ?> </td> </tr> </table> </td> </tr> </table> <?php $h->endpage(); ?> Edited December 1, 2011 by IsaacP fix mistake Quote Link to comment Share on other sites More sharing options...
mixmaster Posted December 2, 2011 Share Posted December 2, 2011 this is the full code I'm using <?php /* EXPLORE THE STREETS CREATED BY: Lithium ~ 03/01/2010 UPDATED BY: Curt ~ 08/03/2011 This feature is 100% free. Enjoy. */ include(DIRNAME(__FILE__) ."/globals.php"); ?> <table cellpadding="4" style="width: 415px; margin-top: 20px;" align="center"> <tr> <td style="background-image: url('images/gradbg.gif'); background-repeat: no-repeat;"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="401" style="background-image: url('images/newsbarhead.gif');" colspan="2" height="20" align="center"> <span class="title">Explore the Streets</span> </td> </tr> <tr> <td colspan="2" class="newspost"> <?php if(!$ir['street_turns']) { echo "You can't explore anymore today!"; $h->endpage(); exit; } if($ir['hospital']) { echo "You can't explore while injured."; $h->endpage(); exit; } if($ir['jail']) { echo"You can't explore while in jail."; $h->endpage(); exit; } $l = $db->query("SELECT * FROM `streets` WHERE (`location` = '{$ir['location']}' OR `location` = '0') ORDER BY RAND() LIMIT 1"); if($_GET['step'] == 'explore') { $db->query("UPDATE `users` SET `street_turns` = `street_turns` - '1' WHERE `userid` = $userid"); $ir['street_turns']-=1; if($db->num_rows($l)) { $step = mysql_fetch_assoc($l); $str = $step['reward']; @eval("\$str = $str;"); if ($step['reward_type'] == 'hospital') { $db->query("UPDATE `users` SET `hp` = '1', `hospital` = '{$str}', `hospreason` = '{$step['reason']}' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'jail') { $db->query("UPDATE `users` SET `jail` = '{$str}', `jailreason` ='{$step['reason']}' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'item') { item_add($userid, $str, 1); } else if ($step['reward_type'] == 'robbed') { if ($ir['money']<$str) { $str=$ir['money']; } rand(5,20)*$ir['level']; $db->query("UPDATE `users` SET `money` = `money` - '$str' WHERE `userid` = $userid"); if ($ir['crystals']<$str) { $str=$ir['crystals']; } rand(5,20)*$ir['level']; $db->query("UPDATE `users` SET `crystals` = `crystals` - '$str' WHERE `userid` = $userid"); } else if ($step['reward_type'] == 'nothing') {} else { $db->query("UPDATE `users` SET `".$step['reward_type']."` = `".$step['reward_type']."` + '$str' WHERE `userid` = $userid"); } $what = array('{money}','{crystals}','{hospital}','{jail}' ,'{nothing}','{item}','{robbed}','{exp}'); $for = is_numeric($str) ? number_format($str) : $str; echo str_replace($what, $for, stripslashes(htmlspecialchars($step['text']))); } ?> <a href="streets.php?step=explore">Continue Exploring</a> <a href="index.php">Back Home</a> You have <?php echo $ir['street_turns']; ?> turns left. <?php } else { ?> <a href="streets.php?step=explore">Explore The City</a> You have <?php echo $ir['street_turns']; ?> turns left. <?php } ?> </td> </tr> </table> </td> </tr> </table> <?php $h->endpage(); ?> We still don't know what error you are getting Quote Link to comment Share on other sites More sharing options...
IsaacP Posted December 2, 2011 Author Share Posted December 2, 2011 Explore the Streets QUERY ERROR: Unknown column 'jailreason' in 'field list' Query was UPDATE `users` SET `jail` = '50', `jailreason` ='Trying to rob a bank.' WHERE `userid` = 1 ok this is the error Quote Link to comment Share on other sites More sharing options...
chicka Posted December 3, 2011 Share Posted December 3, 2011 my streets gives me an error with this query and won't put the person in jail else if ($step['reward_type'] == 'jail') { $db->query("UPDATE `users` SET `jail` = '{$str}', `jailreason ='{$step['reason']}' WHERE `userid` = $userid"); else if ($step['reward_type'] == 'jail') { $db->query("UPDATE `users` SET `jail` = '{$str}', `jail_reason' ='{$step['reason']}' WHERE `userid` = $userid"); That should work for ya :D Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted December 3, 2011 Share Posted December 3, 2011 (edited) @chicka... look at your code lol. you have `jail_reason' may not work i think it should be `jail_reason` (back ticks aren't really needed though)... IF he/she has added the sql for the modification as in the error is saying they don't have it in their database. else if ($step['reward_type'] == 'jail') { $db->query("UPDATE users SET jail= '{$str}', jail_reason='{$step['reason']}' WHERE userid= $userid"); Edited December 3, 2011 by lucky3809 Quote Link to comment Share on other sites More sharing options...
IsaacP Posted December 3, 2011 Author Share Posted December 3, 2011 damn, I don't even seem to notice the obvious, thanks for helping Quote Link to comment Share on other sites More sharing options...
chicka Posted December 3, 2011 Share Posted December 3, 2011 @chicka... look at your code lol. you have `jail reason' may not work i think it should be `jail_reason` (back ticks aren't really needed though)... IF he/she has added the sql for the modification as in the error is saying they don't have it in their database. um double check my code it clearly says jail_reason. Mccodes v2's user table is jail_reason and not jailreason and thats why he's getting the error. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted December 3, 2011 Share Posted December 3, 2011 didnt mean the underslash you had a back tick and a ' if you use both together you get an error. Quote Link to comment Share on other sites More sharing options...
chicka Posted December 3, 2011 Share Posted December 3, 2011 didnt mean the underslash you had a back tick and a ' if you use both together you get an error. would have worked either way. His error wasn't the back ticks it was the missing table Quote Link to comment Share on other sites More sharing options...
gurpreet Posted December 3, 2011 Share Posted December 3, 2011 Lucky was saying that you put: `jail_reason' - Note the ' at the end, not a ` When it should be: `jail_reason` Quote Link to comment Share on other sites More sharing options...
chicka Posted December 3, 2011 Share Posted December 3, 2011 Lucky was saying that you put: `jail_reason' - Note the ' at the end, not a ` When it should be: `jail_reason` ah yes indeed.. My bad sorry :D 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.