Revolution-NOTL Posted February 14, 2014 Share Posted February 14, 2014 Hello. I tried to re-code Richards business cron. But I have few errors, I am willing to pay £2 if someone gets it fixed. <?php require_once(dirname(__FILE__) . "/../mysql.php"); require_once(dirname(__FILE__) . "/../global_func.php"); $cron_code = '****OFF'; if ($argc == 2) { if ($argv[1] != $cron_code) { exit; } } else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) { exit; } $select = mysql_query("SELECT * FROM business LEFT JOIN business_classes ON (classId = busClass) ORDER BY busId ASC"); while($business= mysql_fetch_assoc($select)) { $amount=mysql_num_rows(mysql_query("SELECT * FROM businesses_members WHERE `bmembBusiness = {$business['busId']})); $new_costumer = ($business['classCost'] / 5000) * ($amount + 1) + rand(-12, 18)) / 2); $new_profit = (($new_customers + rand(-4, 8)) * ((($business['classCost'] / 2500) * rand(2, 8)) / 10) * ($amount + 1)); $profit = $new_profit - $business['busCash']; mysql_query("UPDATE businesses SET busYCust = busCust, busYProfit = busProfit, busCust = $new_customers, busProfit = $new_profit, busCash = busCash + $profit WHERE busId = {$business['busId']}"); $fetch_members = mysql_query("SELECT * FROM businesses_members LEFT JOIN users ON (userid = bmembMember) LEFT JOIN businesses_ranks ON (rankId = bmembRank) WHERE bmembBusiness = $business['busId']}"); while($member = mysql_fetch_assoc($fetch_members)) { $fetch_stat = array( 'strength' => 'Strength', 'iq' => 'IQ', 'labour' => 'Labour '); mysql_query("UPDATE users SET money = money + {$member['bmembCash']} WHERE userid = {$member['userid']}"); mysql_query("UPDATE userstats SET {$fetch_stat[$member['rankPrim']]} = {$fetch_stat[$member['rankPrim']]} + {$member['rankPGain']}, {$fetch_stat[$member['rankSec']]} = {$fetch_stat[$member['rankSec']]} + {$member['rankSGain']} WHERE userid ={$member['userid']}"); if($business['busCash'] < $member['bmembCash']) { $text = "". username($member['bmembMember']) ." was not paid \$" . number_format($fm['bmembCash']) . " due to lack of funds."; mysql_query("INSERT INTO businesses_alerts (alertId, alertBusiness, alertText, alertTime) VALUES ('NULL', {$business['busId']}, $text,unix_timestamp()"); mysql_query("UPDATE businesses SET busDebt = busDebt + {$member['bmembCash']} WHERE busId = {$business['busId']}"); } else { mysql_query("UPDATE businesses SET busCash = busCash - {$member['bmembCash']} WHERE busId = {$business['busId']}"); } } if($business['busDebt'] > $business['classCost']) { $send_event = mysql_query(sprintf("SELECT `bmembMember` FROM WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC", $bs['busId'])); while($se = mysql_fetch_assoc($send_event)) { $text = "The {$business['busName']} business went bankrupt\, all members have been discharged."; event_add($se['bmembMember'], "$text"); } mysql_query("DELETE FROM businesses_members WHERE bmembBusiness = {$business['busId']}"); mysql_query("DELETE FROM businesses WHERE busId = {$business['busId']}"); } } Quote Link to comment Share on other sites More sharing options...
Zettieee Posted February 14, 2014 Share Posted February 14, 2014 (edited) Post the errors I'll have a try :) Try this: <?php require_once(dirname(__FILE__) . "/../mysql.php"); require_once(dirname(__FILE__) . "/../global_func.php"); $cron_code = '****OFF'; if ($argc == 2) { if ($argv[1] != $cron_code) { exit; } } else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) { exit; } $select = mysql_query("SELECT * FROM business LEFT JOIN business_classes ON (classId = busClass) ORDER BY busId ASC"); while($business= mysql_fetch_assoc($select)) { $amount=mysql_num_rows(mysql_query("SELECT * FROM businesses_members WHERE `bmembBusiness` = '".$business['busId']."'")); $new_costumer = ($business['classCost'] / 5000) * ($amount + 1) + rand(-12, 18)) / 2); $new_profit = (($new_customers + rand(-4, 8)) * ((($business['classCost'] / 2500) * rand(2, 8)) / 10) * ($amount + 1)); $profit = $new_profit - $business['busCash']; mysql_query("UPDATE businesses SET busYCust = busCust, busYProfit = busProfit, busCust = '".$new_customers."', busProfit = '".$new_profit."', busCash = busCash + '".$profit."' WHERE busId = '".$business['busId']."'"); $fetch_members = mysql_query("SELECT * FROM businesses_members LEFT JOIN users ON (userid = bmembMember) LEFT JOIN businesses_ranks ON (rankId = bmembRank) WHERE bmembBusiness = '".$business['busId']."'"); while($member = mysql_fetch_assoc($fetch_members)) { $fetch_stat = array( 'strength' => 'Strength', 'iq' => 'IQ', 'labour' => 'Labour '); mysql_query("UPDATE users SET money = money + '".$member['bmembCash']."' WHERE userid = '".$member['userid']."'"); mysql_query("UPDATE userstats SET '".$fetch_stat[$member['rankPrim']]."' = '".$fetch_stat[$member['rankPrim']]."' + '".$member['rankPGain']."', '".$fetch_stat[$member['rankSec']]."' = '".$fetch_stat[$member['rankSec']]."' + '".$member['rankSGain']."' WHERE userid = '".$member['userid']."'"); if($business['busCash'] < $member['bmembCash']) { $text = "". username($member['bmembMember']) ." was not paid \$" . number_format($fm['bmembCash']) . " due to lack of funds."; mysql_query("INSERT INTO businesses_alerts (alertId, alertBusiness, alertText, alertTime) VALUES ('NULL', {$business['busId']}, $text,unix_timestamp()"); mysql_query("UPDATE businesses SET busDebt = busDebt + {$member['bmembCash']} WHERE busId = {$business['busId']}"); } else { mysql_query("UPDATE businesses SET busCash = busCash - {$member['bmembCash']} WHERE busId = {$business['busId']}"); } } if($business['busDebt'] > $business['classCost']) { $send_event = mysql_query(sprintf("SELECT `bmembMember` FROM WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC", $bs['busId'])); while($se = mysql_fetch_assoc($send_event)) { $text = "The {$business['busName']} business went bankrupt\, all members have been discharged."; event_add($se['bmembMember'], "$text"); } mysql_query("DELETE FROM businesses_members WHERE bmembBusiness = '".$business['busId']."'"); mysql_query("DELETE FROM businesses WHERE busId = '".$business['busId']."'"); } } ?> Edited February 14, 2014 by Zettieee Quote Link to comment Share on other sites More sharing options...
Revolution-NOTL Posted February 14, 2014 Author Share Posted February 14, 2014 (edited) Hey Zettieee, thanks for the help :) Error - Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home//public_html//business_cron.php on line 20 Line - while($business= mysql_fetch_assoc($select)) { Edited February 14, 2014 by Revolution-NOTL Quote Link to comment Share on other sites More sharing options...
Zettieee Posted February 14, 2014 Share Posted February 14, 2014 $select = mysql_query("SELECT * FROM business LEFT JOIN business_classes ON (classId = busClass) ORDER BY busId ASC"); This is the problem. You are missing a mysql table. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 15, 2014 Share Posted February 15, 2014 $select = mysql_query("SELECT * FROM business LEFT JOIN business_classes ON (classId = busClass) ORDER BY busId ASC"); This is the problem. You are missing a mysql table. Or column :) Quote Link to comment Share on other sites More sharing options...
Revolution-NOTL Posted February 18, 2014 Author Share Posted February 18, 2014 Thanks Zettiee and !Angle life savers you guys are! Quote Link to comment Share on other sites More sharing options...
The Coder Posted February 18, 2014 Share Posted February 18, 2014 Thanks Zettiee and !Angle life savers you guys are! Lol beg? TooShort. 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.