HITMAN 17 Posted January 26, 2009 Posted January 26, 2009 please can someone find out why this dont run <?php require "mysql.php"; require "../../../../global_func.php"; global $c; mysql_query("UPDATE ocs SET oc_hours=oc_hours-1 WHERE oc_hours>0",$c); $q=mysql_query("SELECT * FROM ocs WHERE oc_hours=0",$c); while($r=mysql_fetch_array($q)) { $g=mysql_query("SELECT * FROM gangs WHERE gangID='{$r['oc_gang']}'",$c); $gang=mysql_fetch_array($g); $o=mysql_query("SELECT * FROM orgcrimes WHERE ocID='{$r['oc_type']}'",$c); $oc=mysql_fetch_array($o); print "{$oc['ocNAME']} selected! "; print "{$gang['gangNAME']} selected! "; $a=mysql_query("SELECT * FROM oc_joined WHERE gang='{$r['oc_gang']}' AND oc='{$r['oc_id']}'",$c); if(mysql_num_rows($a) < $oc['ocUSERS']) { print "$suc = 0! "; $suc=0; } else if(mysql_num_rows($a) >= $oc['ocUSERS']) { $totallevel=0; while($b=mysql_fetch_array($a)) { print "query oc_joined table "; $users=mysql_query("SELECT * FROM users WHERE userid='{$b['user']}'",$c); while($user=mysql_fetch_array($users)) { print "query users table "; $totallevel+=$user['level']; } } print "$totallevel"; $suc=$totallevel; $passfail=(rand(1,5)); if($passfail == 1) { $suc=0; } if($suc >= $oc['ocDIFFICULTY']) { print "succeed!"; $rgain=(int)((rand(1,2))+$oc['ocID']); $log=$oc['ocSTARTTEXT'].$oc['ocSUCCTEXT']; $muny=(int) (rand($oc['ocMINMONEY'],$oc['ocMAXMONEY']))*$oc['ocUSERS']; $log=str_replace(array("{muny}","'"),array($muny,"''"),$log); mysql_query("UPDATE gangs SET gangMONEY=gangMONEY+$muny,gangRESPECT=gangRESPECT+$rgain WHERE gangID={$gang['gangID']}",$c) or die(mysql_error()); mysql_query("INSERT INTO oclogs VALUES ('','{$oc['ocID']}','{$gang['gangID']}', '$log', 'Success', '$muny', '{$oc['ocNAME']}', unix_timestamp(), '$rgain')",$c); $i=mysql_insert_id($c); $qm=mysql_query("SELECT * FROM users WHERE gang={$gang['gangID']}",$c); while($rm=mysql_fetch_array($qm)) { event_add($rm['userid'],"Your Gang's Organised Crime Succeeded. Go [url='oclog.php?ID=$i']here[/url] to view the details.",$c) or die(mysql_error()); } // end loop } //end if they win else if ($suc < $oc['ocDIFFICULTY']) { print "fail"; $log=$oc['ocSTARTTEXT'].$oc['ocFAILTEXT']; $muny=0; $log=str_replace(array("{muny}","'"),array($muny,"''"),$log); mysql_query("INSERT INTO oclogs VALUES ('','{$oc['ocID']}','{$gang['gangID']}', '$log', 'Failure', '$muny', '{$oc['ocNAME']}', unix_timestamp(), '0')",$c); $i=mysql_insert_id($c); $qm=mysql_query("SELECT * FROM users WHERE gang={$gang['gangID']}",$c); while($rm=mysql_fetch_array($qm)) { $hosp=(int)(rand(100,250)); mysql_query("UPDATE users SET hospital=hospital+$hosp,hospreason='Failed Organised Crime' WHERE userid='{$rm['userid']}'",$c); event_add($_GET['ID'],"Your Gang's Organised Crime Failed. Go [url='oclog.php?ID=$i']here[/url] to view the details.",$c); }//end loop }//end fail } mysql_query("DELETE FROM oc_joined WHERE oc='{$r['oc_id']}'",$c); mysql_query("DELETE FROM ocs WHERE oc_id='{$r['oc_id']}'",$c); } ?> Quote
HITMAN 17 Posted January 26, 2009 Author Posted January 26, 2009 Re: wont run? i have and nothing works karlos like the event and hosp and such Quote
CLANG Posted January 26, 2009 Posted January 26, 2009 Re: wont run? it could be a stupid mistake like you've not added your crons? Quote
AlabamaHit Posted January 27, 2009 Posted January 27, 2009 Re: wont run? make sure your link to global_func.php is right. that will make events work. and your mysql.php as well.. Quote
Isomerizer Posted January 28, 2009 Posted January 28, 2009 Re: wont run? Well, the loop(s) aren't executing. The main loop that's triggered by this query, may be broke SELECT * FROM ocs WHERE oc_hours=0 Try running this in PHPMYADMIN manually. If its broke, phpmyadmin will respond with an error. Or.. The query triggering the loops calling the event function is: SELECT * FROM users WHERE gang={$gang['gangID']} Where is $gang defined? Try adding global $gang; under global $c; Remember to global them variables being included from external scripts! If its still failing, try running the queries manually via phpmyadmin. This allways helps me. 99% of my scripts fail without any warnings/errors due to query errors. (Poor method I use, i must admit) Good luck. 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.