$nukes = $_POST['target' . $i . '_nukes'];
                                                            $neutron = $_POST['target' . $i . '_neutron'];
                                                            if ($terrname != '-- None --' and $nukes + $neutron > 0) {
                                                                $war_array .= "<TARGET><terrname>{$terrname}</terrname><nuke>{$nukes}</nuke><neutron>{$neutron}</neutron></TARGET>";
                                                            }
                                                            $i++;
                                                        }
                                                        $query = "call sr_4_warheads({$gameno}, '{$powername}', '{$war_array}');";
                                                    } else {
                                                        if ($Action == 'Space') {
                                                            $query = "call sr_4_spaceblast({$gameno}, '{$powername}', '{$_POST['space_nukes']}');";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
// Process query
require_once "utl_multi_query.php";
$query_out = utl_multi_query("set @sr_debug='Y'; select 'BEFORE', powername, userno, minerals, oil, grain from sp_resource where gameno={$gameno}; {$query} select 'AFTER', powername, userno, minerals, oil, grain from sp_resource where gameno={$gameno}; set @sr_debug='N';");
// Email output to admin
$mysqli->query("insert into sp_old_orders (gameno, userno, turnno, phaseno, ordername, order_code) values ({$gameno},{$userno},{$turnno},{$phaseno},'PHASE4_DEBUG','" . addslashes($query_out) . "');") or die("INSERT_QUERY_OUT:" . $mysqli->error);
<?php

// Process orders from phase 7
// $Id: process_phase7.php 107 2012-08-23 00:06:26Z paul $
//? Assume no bad submits
$_SESSION['work'] = "ing";
// Buy the card, or assume pass
require_once "utl_multi_query.php";
if ((isset($_POST['CardNo']) ? $_POST['CardNo'] : -1) > 0) {
    $query_out = utl_multi_query("set @sr_debug='Y';call sr_acquire_comp({$gameno}, {$_POST['CardNo']}, '{$powername}');set @sr_debug='N';");
} else {
    $mysqli->query("Update sp_orders Set order_code='Passed' Where gameno={$gameno} and userno={$userno} and turnno={$turnno} and phaseno={$phaseno} and ordername='ORDSTAT'") or die($mysqli->error);
    require_once "utl_multi_query.php";
    $query_out = utl_multi_query("set @sr_debug='Y';call sr_move_queue({$gameno});set @sr_debug='N';");
}