Jump to content
MakeWebGames

query help


IsaacP

Recommended Posts

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 by IsaacP
fix mistake
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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 by lucky3809
Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...