seany123 Posted December 3, 2008 Share Posted December 3, 2008 okay so im making a game, and because my current host doesnt allow Cron jobs... ive had to create my own file which when called it will update my database. what im wanting is for a code which will make it so: $player-> will + 5 but not go higher than $player->maxnerve. the reason i cant give maxnerve a value is because it can change depending on each player. Link to comment https://forums.phpfreaks.com/topic/135416-query-help/ Share on other sites More sharing options...
Mchl Posted December 3, 2008 Share Posted December 3, 2008 UPDATE players SET will = will + 5 WHERE will < maxnerve Link to comment https://forums.phpfreaks.com/topic/135416-query-help/#findComment-705352 Share on other sites More sharing options...
seany123 Posted December 3, 2008 Author Share Posted December 3, 2008 i mean awake and maxawake instead of nerve... but it doesnt matter too much. would this work? if (awake +5 >= maxawake){ $query = $db->execute("update `players` set awake = maxawake WHERE `id`=?", array($player->id)); } if (awake +5 < maxawake){ $query = $db->execute("update `players` set awake + 5 WHERE `id`=?", array($player->id)); } EDIT: it didnt work.... now going to try your way. Link to comment https://forums.phpfreaks.com/topic/135416-query-help/#findComment-705369 Share on other sites More sharing options...
seany123 Posted December 3, 2008 Author Share Posted December 3, 2008 tried UPDATE players SET will = will + 5 WHERE will < maxnerve... didn't work though. Link to comment https://forums.phpfreaks.com/topic/135416-query-help/#findComment-705409 Share on other sites More sharing options...
Mchl Posted December 3, 2008 Share Posted December 3, 2008 Did you get any error messages? Link to comment https://forums.phpfreaks.com/topic/135416-query-help/#findComment-705411 Share on other sites More sharing options...
Maq Posted December 3, 2008 Share Posted December 3, 2008 Can you please: 1) echo out $query. 2) add or die(mysql_error()) to the end of your queries. 3) add this to the top of your script: ini_set ("display_errors", "1"); error_reporting(E_ALL); Not sure but I think you also need to do: if((awake+5) >= maxawake) { Link to comment https://forums.phpfreaks.com/topic/135416-query-help/#findComment-705415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.