Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Help: Change all users at once? [Answered] (http://www.mysidiaadoptables.com/forum/showthread.php?t=1331)

Magnie 03-05-2010 09:56 AM

Help: Change all users at once? [Answered]
 
Please move this to The Webmaster Bat-Cave, I put this in the wrong section, sorry!

( I may figure this out on my own :P ) Note: This isn't very related to the adoptable script, I'm making a game that is using the adoptable script as a... template you might say to run the game.

Okay, I am trying to make it so a user gets 100 Cash every five minutes, I've got it so the script/file will run every five minutes, I just can't get all the users getting 100 Cash. Only one user at a time, I'm trying to take the "User list" and have that update the user accounts resources, but, that doesn't seem to be working. :/ Here is the code that is suppose to be updating the users' resources:

PHP Code:

$query "SELECT * FROM ".$prefix."users";

$result mysql_query($query);



//Loop out code

$i=0;

while (
$i $num2) {


$user=@mysql_result($result,$i,"username");

$cash=@mysql_result($result,$i,"cash");

$metal=@mysql_result($result,$i,"metal");

$power=@mysql_result($result,$i,"power");

$fuel=@mysql_result($result,$i,"fuel");



$cashs $cash 100;
$metals $metal 75;
$powers $power 25;
$fuels $fuel 50;

$query "UPDATE ".$prefix."users SET cash='".$cashs."' WHERE username='".$user."'";

mysql_query($query);



$query "UPDATE ".$prefix."users SET metal='".$metals."' WHERE username='".$user."'";

mysql_query($query);



$query "UPDATE ".$prefix."users SET fuel='".$fuels."' WHERE username='".$user."'";

mysql_query($query);

$query "UPDATE ".$prefix."users SET power='".$powers."' WHERE username='".$user."'";

mysql_query($query);



$i++;



Any ideas? ( I know it says fuel, metal, power, and cash and that stuff, but as I said before, this is for a game that isn't related to adoptables. ;) )

Arianna 03-05-2010 10:45 AM

RE: Help: Change all users at once?
 
You're running 3 queries per user - that's a lot. I'd update them all in one query.
$query = "UPDATE ".$prefix."users SET cash='".$cashs."' AND metal='".$metals."' AND fuel='".$fuels."' WHERE username='".$user."'";
Next, are you running a cronjob? I have no idea how to get those set up (won't work on my own adoptables site -.-) but if you are and you need help, I'm sure someone else can help. :)

Magnie 03-05-2010 06:39 PM

RE: Help: Change all users at once?
 
I've been wondering how to do multiple of those in one go, thanks! Yeah, I'm running a Cron Job that runs every 5 minutes. ( And still is even though the .php file won't work. ) If you want, I could try to help you get the Cron Job to work, it took my a bit to understand it ( plus some help ).

Seapyramid 03-08-2010 11:32 PM

RE: Help: Change all users at once?
 
you need to use a loop to run though all users to do what you are trying to do, otherwise you will run through the first user only over & over till you time out & chrash your server.

Sea

Magnie 03-09-2010 10:16 AM

RE: Help: Change all users at once?
 
How would I do that though? What's the code?


All times are GMT -5. The time now is 07:32 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.