Tagg Posted November 28, 2008 Share Posted November 28, 2008 I have been getting a few crons up for a game I have been working on. On my latest one I tried something a little above my skill level and need some help now. The way it is suppose to work is there is a database for the users called km_users, where one of the rows is a clan they can join. After they join/create one in the game it sets the name of the clan in that row. Then there is a clan table, km_clan, in that same database (its called a table right?), where I have a row for 'troop power'..which is where I have my problem. I am trying to have a cron update that row regularly by taking all the users from the km_users table with the specific clan name/id and add in all their troops. Btw, there is 2 rows on km_users called 'offarmy' and 'dffarmy'. So basically if 3 users are in the table, and 2 of them are in Clan A - Then the row in km_clan with trooppower would add the 2 users 'offarmy' and 'dffarmy' together and keep the third user to his own clan stats if they are in one. Here is my code, it will update the trooppower row but it posts the same number under each cartel... <?php include "/home/vfelixxv/public_html/ext/connect.php"; if (isset($_SESSION['player'])) { $player=$_SESSION['player']; if(isset($_GET['clan'])) { $userstats="SELECT * from km_users where playername='$player'"; $userstats2=mysql_query($userstats) or die("Could not get user stats"); $userstats3=mysql_fetch_array($userstats2); $getclanstats="SELECT * from km_users where clanname='$userstats3[clanname]'"; $getclanstats2=mysql_query($getclanstats) or die("Could not query stats"); while($getclanstats3=mysql_fetch_array($getclanstats2)) { $skill += $getclanstats3[offarmy]; $atkskill += $getclanstats3[dffarmy]; } $gettrooppower="Update km_clans set trooppower=$skill+$atkskill where name=$clan[name]"; $gettrooppower2=mysql_query($gettrooppower) or die("Could not run trooppower"); } } ?> Link to comment https://forums.phpfreaks.com/topic/134689-having-trouble-setting-up-my-cron-to-request-specific-values/ Share on other sites More sharing options...
trq Posted November 29, 2008 Share Posted November 29, 2008 $_GET and $_SESSION do not exist within a script executed via cron. Your script doesn't really make allot of sense within the context of a cron job. Link to comment https://forums.phpfreaks.com/topic/134689-having-trouble-setting-up-my-cron-to-request-specific-values/#findComment-701392 Share on other sites More sharing options...
Tagg Posted November 29, 2008 Author Share Posted November 29, 2008 Thanks, I was trying some variations and tutorials I was reading through..kind of got mushed in there. Would you know of a good way to call certain values out of the database? I can apply what I need on a php page, but I guess it's useless without a Session selecting what you need..if that makes any sense heh. I'l be on google searching, if its not possible to do this or an alternative way is possible please let me know..you guys rock Link to comment https://forums.phpfreaks.com/topic/134689-having-trouble-setting-up-my-cron-to-request-specific-values/#findComment-701429 Share on other sites More sharing options...
trq Posted November 29, 2008 Share Posted November 29, 2008 Would you know of a good way to call certain values out of the database? You'll need to hard code them into your query. Link to comment https://forums.phpfreaks.com/topic/134689-having-trouble-setting-up-my-cron-to-request-specific-values/#findComment-701476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.