Jump to content
MakeWebGames

Update.php


grant

Recommended Posts

tryed so many ways to fix this ??? need some help pointing me to fix it thanks


$result = mysql_query ("SELECT * FROM `updates` WHERE `name` = 'trevor'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];

}





$timesinceupdate = time() - $update;



if ($timesinceupdate>=300) {



$num_updates = floor($timesinceupdate / 300);



//stock market stuff

$result = mysql_query("SELECT * FROM `stocks`");

while($line = mysql_fetch_assoc($result)) {

	$amount = rand (strlen($line['cost']) * -1, strlen($line['cost']));

	$newamount = $line['cost'] + $amount;

	if ($newamount < 1){

		$newamount = 1;

	}

	$result2 = mysql_query("UPDATE `stocks` SET `cost`='".$newamount."' WHERE `id`='".$line['id']."'");

}

//stock market stuff



$result = mysql_query("SELECT * FROM `grpgusers`");



while($line = mysql_fetch_assoc($result)) {



	$updates_user = new User($line['id']);



	if ($updates_user->rmdays > 0) {



		$multiplier = 2;



	} else {



		$multiplier = 1;



	}



	$username = $updates_user->username;



	$newawake = $updates_user->awake + (5 * $num_updates) * $multiplier;



	$newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake;



	$newhp = $updates_user->hp + (10 * $num_updates) * $multiplier;



	$newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp;



	$newenergy = $updates_user->energy + (2 * $num_updates) * $multiplier;



	$newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy;



	$newnerve = $updates_user->nerve + (2 * $num_updates) * $multiplier;



	$newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve;



	$result2 = mysql_query("UPDATE `grpgusers` SET `awake` = '".$newawake."', `energy` = '".$newenergy."', `nerve` = '".$newnerve."', `hp` = '".$newhp."' WHERE `username` = '".$username."'");



}



//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'trevor'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 300) * 300);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'trevor'");



}



}



















$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'hospital'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];



}



$timesinceupdate = time() - $update;



if ($timesinceupdate>=60) {



$num_updates = floor($timesinceupdate / 60);



$result = mysql_query("SELECT * FROM `grpgusers`");



//DO STUFF



while($line = mysql_fetch_assoc($result)) {



	$result_user = mysql_query("SELECT * FROM `grpgusers` WHERE `id`='".$line['id']."'");



	$updates_user = mysql_fetch_array($result_user);







	$newhospital = $updates_user['hospital'] - (60 * $num_updates);



	$newhospital = ($newhospital < 0) ? 0 : $newhospital;



	$newjail = $updates_user['jail'] - (60 * $num_updates);



	$newjail = ($newjail < 0) ? 0 : $newjail;



	$result2 = mysql_query("UPDATE `grpgusers` SET `hospital` = '".$newhospital."', `jail` = '".$newjail."' WHERE `id` = '".$line['id']."'");



}







$result = mysql_query("SELECT * FROM `effects`");



while($line = mysql_fetch_assoc($result)) {



	if($line['timeleft'] > 0){



	$newamount = $line['timeleft'] - (1 * $num_updates);



	$result2 = mysql_query("UPDATE `effects` SET `timeleft` = '".$newamount."' WHERE `id` = '".$line['id']."'");



	}



}



$result2 = mysql_query("DELETE FROM `effects` WHERE `timeleft` < 1");







//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'hospital'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 60) * 60);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'hospital'");



}



}



Link to comment
Share on other sites

Include the connection file?
well i have tryed the dbcon still the not working here if the code if u have any ideas of wot mite be wrong

 

<?



//Updates



$result = mysql_query ("SELECT * FROM `updates` WHERE `name` = 'trevor'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];

}





$timesinceupdate = time() - $update;



if ($timesinceupdate>=300) {



$num_updates = floor($timesinceupdate / 300);



//stock market stuff

$result = mysql_query("SELECT * FROM `stocks`");

while($line = mysql_fetch_assoc($result)) {

	$amount = rand (strlen($line['cost']) * -1, strlen($line['cost']));

	$newamount = $line['cost'] + $amount;

	if ($newamount < 1){

		$newamount = 1;

	}

	$result2 = mysql_query("UPDATE `stocks` SET `cost`='".$newamount."' WHERE `id`='".$line['id']."'");

}

//stock market stuff



$result = mysql_query("SELECT * FROM `grpgusers`");



while($line = mysql_fetch_assoc($result)) {



	$updates_user = new User($line['id']);



	if ($updates_user->rmdays > 0) {



		$multiplier = 2;



	} else {



		$multiplier = 1;



	}



	$username = $updates_user->username;



	$newawake = $updates_user->awake + (5 * $num_updates) * $multiplier;



	$newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake;



	$newhp = $updates_user->hp + (10 * $num_updates) * $multiplier;



	$newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp;



	$newenergy = $updates_user->energy + (2 * $num_updates) * $multiplier;



	$newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy;



	$newnerve = $updates_user->nerve + (2 * $num_updates) * $multiplier;



	$newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve;



	$result2 = mysql_query("UPDATE `grpgusers` SET `awake` = '".$newawake."', `energy` = '".$newenergy."', `nerve` = '".$newnerve."', `hp` = '".$newhp."' WHERE `username` = '".$username."'");



}



//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'trevor'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 300) * 300);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'trevor'");



}



}



















$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'hospital'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];



}



$timesinceupdate = time() - $update;



if ($timesinceupdate>=60) {



$num_updates = floor($timesinceupdate / 60);



$result = mysql_query("SELECT * FROM `grpgusers`");



//DO STUFF



while($line = mysql_fetch_assoc($result)) {



	$result_user = mysql_query("SELECT * FROM `grpgusers` WHERE `id`='".$line['id']."'");



	$updates_user = mysql_fetch_array($result_user);







	$newhospital = $updates_user['hospital'] - (60 * $num_updates);



	$newhospital = ($newhospital < 0) ? 0 : $newhospital;



	$newjail = $updates_user['jail'] - (60 * $num_updates);



	$newjail = ($newjail < 0) ? 0 : $newjail;



	$result2 = mysql_query("UPDATE `grpgusers` SET `hospital` = '".$newhospital."', `jail` = '".$newjail."' WHERE `id` = '".$line['id']."'");



}







$result = mysql_query("SELECT * FROM `effects`");



while($line = mysql_fetch_assoc($result)) {



	if($line['timeleft'] > 0){



	$newamount = $line['timeleft'] - (1 * $num_updates);



	$result2 = mysql_query("UPDATE `effects` SET `timeleft` = '".$newamount."' WHERE `id` = '".$line['id']."'");



	}



}



$result2 = mysql_query("DELETE FROM `effects` WHERE `timeleft` < 1");







//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'hospital'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 60) * 60);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'hospital'");



}



}



?>
Link to comment
Share on other sites

61 $result = mysql_query("SELECT * FROM `grpgusers`");

 

65 while($line = mysql_fetch_assoc($result)) {

 

69 $updates_user = new User($line['id']);

How about including the class file too?

 

Never worked with GRPG long enough to know it's files but the warning is a pretty good indication.

av give that a go see how it goes thanks
Link to comment
Share on other sites

1.<?php

2.function Get_ID($username){

3.$result = mysql_query("SELECT * FROM `grpgusers` WHERE `username` = '".$username."'");

4.$worked = mysql_fetch_array($result);

5.return $worked['id'];

6.}

7

8.function mrefresh($url, $time="1"){

9.echo '<meta http-equiv="refresh" content="'.$time.';url='.$url.'">';

10.}

well it all the same here so wot mite be the problem

any ideas ?

Link to comment
Share on other sites

  • 1 month later...

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