Jump to content

Trouble with cronjob


Phpfr3ak

Recommended Posts

Don't have a huge deal of experience with this side of things, well php as a whole really but really struggle with this side, ive coded up a cron but it only works for 1 user, unsure as to why, i want it to do the action for every player that has item 17, the codes below any help would be appreciated, Thanks guys

 

<?php
include("server.php");
$sql = "SELECT * FROM player_inventory WHERE item_id = 17";
$que = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($que);
$sql2 = "SELECT * FROM players WHERE id = $res[player_id]";
$que2 = mysql_query($sql2);
while($res2=mysql_fetch_array($que2)) {
$Weight = 8 / 100 * (100 + $res2['ProductionWeight']);
$Quality = 75 / 100 * (100 + $res2['ProductionWeight']);
$StreetCred = $Weight * $Quality / 10;
$update = "UPDATE players SET StreetCred = StreetCred + $StreetCred WHERE id = $res[player_id]";
mysql_query($update) or die(mysql_error());;
$update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res[player_id]',$Quality,$Weight)";
mysql_query($update2) or die(mysql_error());;
echo "Grow Completed.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/255551-trouble-with-cronjob/
Share on other sites

Worked that part out, only query i have now is how do i make it only effect people with item 17 purchased, what i have now;

 

<?php
include("server.php");
$sql = "SELECT * FROM player_inventory WHERE item_id = 17";
$que = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($que);
$sql2 = "SELECT * FROM players";
$que2 = mysql_query($sql2);
while($res2=mysql_fetch_array($que2)) {
$Weight = 8 / 100 * (100 + $res2['ProductionWeight']);
$Quality = 75 / 100 * (100 + $res2['ProductionWeight']);
$StreetCred = $Weight * $Quality / 10;
$update = "UPDATE players SET StreetCred = StreetCred + $StreetCred";
mysql_query($update) or die(mysql_error());;
$update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res2[id]',$Quality,$Weight)";
mysql_query($update2) or die(mysql_error());;
echo "Grow Completed.";
}
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.