peterisgb Posted May 29, 2012 Posted May 29, 2012 i have an interactivem menu in my game, most of it works, i have recently been trying to add in a Crimes page into the menu Below is what i have so far and need a pointer in the right direction its the docrime.php for the menu. the problem that is occuring is it keeps saying "You do not have enough Brave to perform this crime." Thanks <?php $macropage="criminaldocrime.php?c={$_GET['c']}"; session_start(); if (!isset ($_SESSION['userid']) ) { echo '<p>Not logged in.</p>'; exit; } include "config.php"; global $_CONFIG,$set; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $userid = $db->query('SELECT `userid` FROM `users` WHERE (`userid` = '.$_SESSION['userid'].')'); $ir = $db->query('SELECT `userid`, `hospital`, `jail`, `level`, `energy`, `maxenergy`, `will`, `maxwill`, `brave`, `maxbrave`, `exp`, `hp`, `maxhp`, `gymxp`, `gexp_needed` FROM `users` WHERE (`userid` = '.$_SESSION['userid'].')'); $r = $db->query('SELECT `crimeNAME`, `crimeBRAVE`, `crimeID`, `crimePERCFORM`, `crimeITEXT`, `crimeSUCCESSMUNY`, `crimeSTEXT`, `crimeSUCCESSCRYS`, `crimeXP`, `crimeSUCCESSITEM` , `crimeFTEXT`, `crimeJAILTIME`, `crimeJREASON`, `crimeJTEXT` FROM crimes'); if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed while in jail or hospital."); } $_GET['c']=abs((int) $_GET['c']); if(!$_GET['c']) { print "Invalid crime"; } else { $q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}",$c); $r=mysql_fetch_array($q); if($ir['brave'] < $r['crimeBRAVE']) { print "You do not have enough Brave to perform this crime."; } else { $ec="\$sucrate=".str_replace(array("LEVEL","CRIMEXP","EXP","WILL","IQ"), array($ir['level'], $ir['crimexp'], $ir['exp'], $ir['will'], $ir['IQ']),$r['crimePERCFORM']).";"; eval($ec); print $r['crimeITEXT']; $ir['brave']-=$r['crimeBRAVE']; mysql_query("UPDATE users SET brave={$ir['brave']} WHERE userid=$userid",$c); if(rand(1,100) <= $sucrate) { print str_replace("{money}",$r['crimeSUCCESSMUNY'],$r['crimeSTEXT']); $ir['money']+=$r['crimeSUCCESSMUNY']; $ir['crystals']+=$r['crimeSUCCESSCRYS']; $ir['exp']+=(int) ($r['crimeSUCCESSMUNY']/6); mysql_query("UPDATE users SET money={$ir['money']}, crystals={$ir['crystals']}, exp={$ir['exp']},crimexp=crimexp+{$r['crimeXP']},crimesdone=crimesdone+1 WHERE userid=$userid",$c); if($r['crimeSUCCESSITEM']) { item_add($userid, $r['crimeSUCCESSITEM'], 1); } } else { if(rand(1, 2) == 1) { print $r['crimeFTEXT']; } else { print $r['crimeJTEXT']; $db->query("UPDATE `users` SET `jail` = '$r[crimeJAILTIME]', `jail_reason` = '$r[crimeJREASON]' WHERE `userid` = '$userid'"); } } print "<br /><a href='criminaldocrime.php?c={$_GET['c']}'>Try Again</a><br /> <a href='playerbars.php'>close</a>"; } } $h->endpage(); ?> Quote
rulerofzu Posted May 29, 2012 Posted May 29, 2012 Your queries are a bit wrong. Line 23 your doing a query for the userid. Then on line 26 your doing it again. Line 26 is not actually getting a result. Your making the query but no result. So you can get rid of one of those. Line 29 is not required as your doing that query on line 40 Quote
peterisgb Posted May 29, 2012 Author Posted May 29, 2012 ok, so what would i need to do to solve this issue, and line 23 was given to my in another post i made a while back, Quote
rulerofzu Posted May 30, 2012 Posted May 30, 2012 query the database $db->query fetch the results from the query $db->fetch_row Your making the query but not fetching the results $ir_query=$db->query('select userid from users where userid='.$_SESSION['userid'].''); $ir=$db->fetch_row($ir_query); This would be done already if you included the globals.php unless you cannot due to the interactive menu. Quote
peterisgb Posted May 30, 2012 Author Posted May 30, 2012 yeah, i cannot use the globals and its in the interactive menu, I have managed to get several other pages working fine within the interactive menu which are, Armoury, Shortcuts, - Basic Bank - Credit Card - Cyber Bank - Point Bank - Point Trader - Gym - Crimes (this is the one in question. Player Stats, Player Bars, Energy Refill in tab 2, Its Just this page is the one getting me lol, i just dont get why all these pages work and the crimes does not. One this is compeleted and finnished totall i might release it. Quote
rulerofzu Posted May 31, 2012 Posted May 31, 2012 As your calling the db class then you should use $db-> otherwise no point in calling the class. Quote
peterisgb Posted May 31, 2012 Author Posted May 31, 2012 still didnt work, maybe i am blind and cant see the problems lol would someone do a patch up so it will work and i will read it and learn my errors. Quote
peterisgb Posted June 6, 2012 Author Posted June 6, 2012 any help on this. once this is done i can release this mod, (free) Quote
peterisgb Posted June 7, 2012 Author Posted June 7, 2012 its working now but i kinda got a little problem. $_GET['c']=abs((int) $_GET['c']); if(!$_GET['c']) These Lines grabs the Number from the Address bar, as its in the inteactive menu how do i get the GET to collect the link from an iframe? Quote
peterisgb Posted June 9, 2012 Author Posted June 9, 2012 2 = Iframes. Custom Criminal is in Iframe1. In Iframe 1 is, crime Name, Crime Brave and Crime Do Crime Do is then sent to Iframe2. But iframe 2 just says "You do not have enough Brave to perform this crime." In this case its not collecting the GET c from Iframe1 for Iframe2. How do i get the GET from Iframe2 to find the GET c from Iframe1. Help would be alot of help. thanks Quote
rulerofzu Posted June 10, 2012 Posted June 10, 2012 Do it in javascript/ajax on the page rather than iframe to iframe Quote
peterisgb Posted June 10, 2012 Author Posted June 10, 2012 i dont know knowthing about javascript lol 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.