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
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.";
}
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

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.