HITMAN 17 Posted October 26, 2008 Posted October 26, 2008 i am trying to make v1 when you fail a crime you go to jail but have this error on criminal.php Warning: Invalid argument supplied for foreach() in /home/chav1/public_html/criminal.php on line 37 can someone help me i asked nyna and got no reply so here is the part of the code $q=mysql_query("SELECT * FROM crimegroups ORDER by cgORDER ASC"); print "[b]Criminal Centre[/b] <table width='75%' cellspacing=1 class='table'><tr><th>Crime</th><th>Cost</th><th>Do</th></tr>"; while($r=mysql_fetch_array($q)) { print "<tr><td colspan='3' class='h'>{$r['cgNAME']}</td></tr>"; foreach($crimes as $v); { if($v['crimeGROUP'] == $r['cgID']) { print "<tr><td>{$v['crimeNAME']}</td><td>{$v['crimeBRAVE']} Brave</td><td>[url='docrime.php?c={$v[']Do[/url]</td></tr>"; } } } Quote
radio_active Posted October 26, 2008 Posted October 26, 2008 Re: Im trying to do make v1... Try posting your docrime.php for starters Quote
HITMAN 17 Posted October 26, 2008 Author Posted October 26, 2008 Re: Im trying to do make v1... ok here is my docrime.php <?php /*----------------------------------------------------- -- Your Game Name v1.0 BETA -- A product of DBS-entertainment -- Copyright held 2005 by Dabomstew, ColdBlooded -- INDEX.php -----------------------------------------------------*/ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); 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']/8); mysql_query("UPDATE users SET money={$ir['money']}, crystals={$ir['crystals']}, exp={$ir['exp']},crimexp=crimexp+{$r['crimeXP']} 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']; mysql_query("UPDATE `users` SET `jail` = '$r[crimeJAILTIME]', `jail_reason` = '$r[crimeJREASON]' WHERE `userid` = '$userid'"); } } print " [url='docrime.php?c={$_GET[']Try Again[/url] [url='criminal.php']Crimes[/url]"; } } $h->endpage(); ?> btw this isnt th orginal v1 docrime Quote
radio_active Posted October 26, 2008 Posted October 26, 2008 Re: Im trying to do make v1... Correct me if im wrong anyone but on the if(rand(1, 2) == 1) { print $r['crimeFTEXT']; } else { print $r['crimeJTEXT']; mysql_query("UPDATE `users` SET `jail` = '$r[crimeJAILTIME]', `jail_reason` = '$r[crimeJREASON]' WHERE `userid` = '$userid'"); } } The mysql query should be an INSERT INTO rather then an UPDATE? eg mysql_query("INSERT INTO `jail` VALUES (' ','$r[crimeJAILTIME]', '$r[crimeJREASON]') WHERE `userid` = '$userid'"); I know that query is wrong but here is a problem i believe. You had update users set jail = blah blah jail is a single row in the users table, you have to make a seperate field called jail (otherwise you are trying to insert two things into a single row) and then have something similar to what i posted and then maybe have a query after that which is UPDATE users set jail = jail + $jailtime the variable being the time that you go to jail for. Quote
radio_active Posted October 26, 2008 Posted October 26, 2008 Re: Im trying to do make v1... or if you are using update user you would have to have two rows, jail, jailtext then the queries would be. mysql_query("UPDATE `users` SET `jail` = jail + $r[crimeJAILTIME] WHERE `userid` = '$userid'"); and mysql_query("UPDATE `users` SET `jailtext` = $r[crimeJREASON] WHERE `userid` = '$userid'"); PS, im about 100% sure those queries will not work... lol Quote
HITMAN 17 Posted October 26, 2008 Author Posted October 26, 2008 Re: Im trying to do make v1... OK IM ON THE EDGE OF GIVING UP AS THATS NOT HELPING Please add me on msn is ent you pm Quote
AlabamaHit Posted October 26, 2008 Posted October 26, 2008 Re: Im trying to do make v1... dont get damn rude..you will not get help..... If you dont understand you DONT need a game.. LEARN TO CODE... Your asking for help. I be DAMN if i just tell people how to fix crap.. I hate when someoen tells me HOW to fix something i ask about... I want to know WHY..so i can learn. you dont want to learn shit you just want stuff for free.......codes also maybe....screw you man..i cant stand rude people..... that guy is trying to help you and Point you in the right direction....Nothign more... 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.