Jump to content
MakeWebGames

Paying £2...


Revolution-NOTL

Recommended Posts

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']}");
}
}
Link to comment
Share on other sites

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

$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 :)

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