greenbman Posted February 23, 2013 Share Posted February 23, 2013 Ok so I have a function that is adding numbers to row in table and for some reason each type is being limited eg type 1 can only add up to 14 at a time any more that the the function returns e_1. Also type 2 limits $amt to 6 if I input more than 6 eg 7 it returns e_1 as well. And I can do multiple submits of 6 that returns a s_1 which is what I want and I have enough $onhandE to do transaction but for some reason its limiting it. function: <?php function createSloppyCheeseBugs($type, $iron, $plat, $energy, $onhandI, $onhandP, $onhandE, $amt, $id, $pid){ if($type==1){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `smallcargo` = `smallcargo`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==2){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `largecargo` = `largecargo`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==3){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `cruiser` = `cruiser`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==4){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `heavycrusier` = `heavycrusier`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==5){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `warship` = `warship`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==6){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `recycler` = `recycler`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } if($type==7){ $ironAMT = bcmul($iron, $amt); $platAMT = bcmul($plat, $amt); $energyAMT = bcmul($energy, $amt); if($ironAMT<=$onhandI){ if($platAMT<=$onhandP){ if($energyAMT<=$onhandE){ $q="UPDATE `shipyard` SET `slaveship` = `slaveship`+'{$amt}' WHERE `id` = '$id'"; $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'{$ironAMT}', `Plat_Res` = `Plat_Res`-'{$platAMT}', `Energy_Res` = `Energy_Res`-'{$energyAMT}' WHERE `planetID` = '{$planetID}'"; $res = mysql_query($q) or die(mysql_error()); $res2 = mysql_query($q2) or die(mysql_error()); if(isset($res)){ if(isset($res2)){ return "s_1"; } } }else{ return "e_1"; } }else{ return "e_2"; } }else{ return "e_3"; } } } ?> Calling code: if(isset($_POST['hidsc'])){ $amt = anti_injection($_POST['BLDSC']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(1, 85000000, 98000000, 30000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidlc'])){ $amt = anti_injection($_POST['BLDLC']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(2, 185000000, 198000000, 130000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidc'])){ $amt = anti_injection($_POST['BLDC']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(3, 385000000, 398000000, 330000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidhc'])){ $amt = anti_injection($_POST['BLDHC']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(4, 485000000, 498000000, 430000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidw'])){ $amt = anti_injection($_POST['BLDW']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(5, 685000000, 698000000, 630000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidr'])){ $amt = anti_injection($_POST['BLDR']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(6, 25400000, 22540000, 15000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } if(isset($_POST['hidss'])){ $amt = anti_injection($_POST['BLDSS']); $query = "SELECT * FROM `shipyard` WHERE `owner_id` = '{$ui['planetID']}'"; $res = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($res); $res = createSloppyCheeseBugs(7, 15000000, 28000000, 340000, $pi['Iron_Res'], $pi['Plat_Res'], $pi['Energy_Res'], $amt, $row['id'], $ui['planetID']); if(isset($res)){ if($res == "e_1"){ $msg = "Insufficient Iron!"; } if($res == "e_2"){ $msg = "Insufficient Platinum!"; } if($res == "e_3"){ $msg = "Insufficient Energy!"; } if($res == "s_1"){ $msg = "Ship Construction Completed!"; } } } Any help with this would be awesome! greenbman Link to comment https://forums.phpfreaks.com/topic/274868-amt-limited/ Share on other sites More sharing options...
greenbman Posted February 23, 2013 Author Share Posted February 23, 2013 Hahah! I figured it out the return "e_1" to "e_3" were reversed it was that I actually did not have enough iron! Link to comment https://forums.phpfreaks.com/topic/274868-amt-limited/#findComment-1414494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.