Jump to content

[SOLVED] Need some help with the Miners Code


Dethman

Recommended Posts

it keeps giving me this error

 

Warning: Missing argument 5 for traintroops() in /home2/gt/public_html/functions/train2.php on line 14

 

Warning: Missing argument 6 for traintroops() in /home2/gt/public_html/functions/train2.php on line 14

 

Warning: Cannot modify header information - headers already sent by (output started at /home2/gt/public_html/functions/train2.php:14) in /home2/gt/public_html/functions/train2.php on line 50

 

 

Heres train2.php

<?php

function spyBoost($cost,$id){
$q="UPDATE `user_users` SET `credits` =`credits` - '$cost', `covertLVL` = `covertLVL` +'1' WHERE `userid` = '$id'";
mysql_query($q);
header("Location: train.php?strErr=Covert Level Upgraded");
}
function birthBoost($amt,$cost,$id){
$q="UPDATE `user_users` SET `credits` =`credits` - '$cost', `birthrate` = `birthrate` +'$amt' WHERE `userid` = '$id'";
mysql_query($q);
header("Location: train.php?strErr=Birth Rate Upgraded");
}

function trainTroops($atk,$def,$spy,$miners,$tminers,$userid){
$sql="SELECT * FROM `user_users` WHERE `userid` = '$userid'";
$query=mysql_query($sql);
$user=mysql_fetch_array($query);
$atk=floor($atk);
$def=floor($def);
$spy=floor($spy);
$miners=floor($miners);
$tminers=floor($tminers);
if($spy<=0){
$spy=0;
}
if($def<=0){
$def=0;
}
if($atk<=0){
$atk=0;
}
if($miners<=0){
$miners=0;
}
if($tminers<=0){
$tminers<=0;
}
if($user['untrainedTroops']-($atk+$def+$spy+$miners+$timers)>=0){	
	if($user['credits']-((($atk+$def)*3000)+($spy*5000)+($miners*3000)+($tminers*3000))>=0){
	$cost=$spy*5000;
	$cost+=($atk+$def)*3000;
	$cost=$miners*3000;
	$cost=$tminers*3000;
		mysql_query("UPDATE `user_users` SET `Naquadah` = `Naquadah` - '$cost', `attackTroops` = `attackTroops` +'$atk', `defenseTroops` = `defenseTroops` +'$def', `Miners` = `Miners` +'$miners', `TriniumMiners` = `TriniumMiners` +'$tminers',`covertTroops` = `covertTroops` +'$spy', `untrainedTroops` = `untrainedTroops` - '$atk'-'$def'-'$spy'-'$miners'-'$tminers' WHERE `userid` = '$userid'");
		header("Location: train.php?strErr=troops trained");
	}else{
	header("Location: train.php?strErr=not enough Naquadah");
	}
}else{
header("Location: train.php?strErr=not enough Untrained Units");
}
}
function untrainTroops($atk,$def,$spy,$userid){
$sql="SELECT * FROM `user_users` WHERE `userid` = '$userid'";
$query=mysql_query($sql);
$user=mysql_fetch_array($query);
$atk=floor($atk);
$def=floor($def);
$spy=floor($spy);
if($spy<=0){
$spy=0;
}
if($def<=0){
$def=0;
}
if($atk<=0){
$atk=0;
}
if($user['untrainedTroops']-($atk+$def+$spy+$miners+$tminers)>=0){	
	if($user['credits']-((($atk+$def)*000)+($spy*000)+($miners*000)+($tminers*000))>=0){
	$cost=$spy*000;
	$cost+=($atk+$def)*000;
		mysql_query("UPDATE `user_users` SET `Naquadah` = `Naquadah` - '$cost', `attackTroops` = `attackTroops` -'$atk', `defenseTroops` = `defenseTroops` -'$def', `covertTroops` = `covertTroops` -'$spys', `untrainedTroops` = `untrainedTroops` + '$atk'+'$def'+'$spy' WHERE `userid` = '$userid'");
		header("Location: train.php?strErr=troops trained");
	}else{
	header("Location: train.php?strErr=not enough Naquadah");
	}
}else{
header("Location: train.php?strErr=not enough civillians");
}
}
?>

 

Heres train.php

<?php
//start title
$pagetitle="Base";
//end title
require("db_connect.php");
require("functions/global.php");
require("functions/train2.php");

if( isset($_SESSION['userid']) ){
$user=getUserInfo($_SESSION['userid']);
} else {
header("Location: index.php");
}

if($_POST['train']){
$atroop=$_POST['atroop'];
$miners=$_POST['miners'];
$tminers=$_POST['tminers'];
$dtroop=$_POST['dtroop'];
$ctroop=$_POST['ctroop'];
trainTroops($atroop,$dtroop,$ctroop,$user['userid']);
}
if($_POST['untrain']){
$atroop=$_POST['atroop'];
$dtroop=$_POST['dtroop'];
$ctroop=$_POST['ctroop'];
untrainTroops($atroop,$dtroop,$ctroop,$user['userid']);
}
$msg=$_GET['strErr'];

$spycost=pow(2,$user['covertLVL'])*14000;
$birthcost=$user['birthrate']*5000+5000;
if($_POST['spylvl']){
if($user['Naquadah']-$spycost>=0){
spyBoost($spycost,$user['userid']);
}else{
header("Location: train.php?strErr=not enough naquadah");
}
}
if($_POST['birthlvl']){
$amt=floor($_POST['birthamt']);
if($amt>0){
	if($user['Naquadah']-($birthcost*$amt)>=0){
	birthBoost($amt, ($birthcost*$amt),$user['userid']);
	}else{
	header("Location: train.php?strErr=not enough naquadah");
	}
}
}
include("includes/header.php");
?>
<html>
<head>
</head>
<body>
<center><Table width=100% cellspacing=1 cellpadding=5>
<tr>
<td width=15% valign=top><?php include("includes/navi.php"); ?></td><td valign=top>
<?php if($msg!=""){ ?><b><i><center><font size=+0><?php echo($msg); ?></font></center></i></b> <?php } ?>
    <table width="100%" border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td valign=top width=55%><table width="100%" cellpadding="0" cellspacing="0" class="table_lines">
          <tr>
            <th colspan="3">Military Effectiveness</th>
          </tr>
          <tr>
            <td><strong>Overall</strong></td>
            <td align="right"><?php echo(number_format(getAtkPow($user['userid'])+getDefPow($user['userid'])+getSpyPow($user['userid']))); ?></td>
            <td align="right">Ranked: <?php echo(number_format($user['overallRank'])); ?></td>
          </tr>
          <tr>
            <td><strong>Strike Action</strong></td>
            <td align="right"><?php echo(number_format(getAtkPow($user['userid']))); ?></td>
            <td align="right">Ranked: <?php echo(number_format($user['attackRank'])); ?></td>
          </tr>
          <tr>
            <td><strong>Defensive Action</strong></td>
            <td align="right"><?php echo(number_format(getDefPow($user['userid']))); ?></td>
            <td align="right">Ranked: <?php echo(number_format($user['defenseRank'])); ?></td>
          </tr>
          <tr>
            <td><strong>Covert Action</strong></td>
            <td align="right"><?php echo(number_format(getSpyPow($user['userid']))); ?></td>
            <td align="right" valign="top">Ranked: <?php echo(number_format($user['covertRank'])); ?></td>
          </tr>
          <tr>
            <td><strong>Mothership Action</strong></td>
            <td align="right"><font size=-1><?php echo(number_format(getFleetPower($user['userid']))); ?></font></td>
            <td align="right">Ranked: <?php echo(number_format($user['fleetRank'])); ?></td>
          </tr>
        </table>
          <br>
          <table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_lines">
            <tr>
              <th align=center colspan=2>Population</th>
                
          </tr>
            <tr>
              <td>Attackers </td>
                <td align="right"><?php echo(number_format($user['attackTroops'])); ?></td>
              </tr>
            <tr>
              <td>Defenders</td>
                <td align="right"><?php echo(number_format($user['defenseTroops'])); ?></td>
              </tr>
            <tr>
              <td>Untrained Unit</td>
                <td align="right"><?php echo(number_format($user['untrainedTroops'])); ?></td>
              </tr>
            <tr>
              <td>Covert Operative </td>
                <td align="right"><?php echo(number_format($user['covertTroops'])); ?></td>
              </tr>
          </table>		</td><td valign=top><br>
          <form name="form1" method="post" action="">
            <table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_lines">
              <tr>
                <th scope="col" colspan=3>Troop Academy </th>
              </tr>
              <tr>
                <td>Troop name</td>
                <td>Cost</td>
                <td>Amount</td>
              </tr>
              <tr>
                <td>Miners </td>
                <td>3,000 Naquadah </td>
                <td><label>
                  <div align="center">
                    <input name="miners" type="text" id="miners" size="6" maxlength="3">
                    </div>
                </label></td>
              </tr>
              <tr>
                <td>Trinium Miners</td>
                <td>3,000 Naquadah </td>
                <td><label>
                  <div align="center">
                    <input name="tminers" type="text" id="tminers" size="6" maxlength="3">
                    </div>
                </label></td>
              </tr>
              <tr>
                <td>Attacker </td>
                <td>3,000 Naquadah </td>
                <td><label>
                  <div align="center">
                    <input name="atroop" type="text" id="atroop" size="6" maxlength="3">
                    </div>
                </label></td>
              </tr>
              <tr>
                <td>Defender</td>
                <td>3,000 Naquadah </td>
                <td><div align="center">
                  <input name="dtroop" type="text" id="dtroop" size="6" maxlength="3">
                </div></td>
              </tr>
              <tr>
                <td>Covert Operative </td>
                <td>5,000 Naquadah </td>
                <td><div align="center">
                  <input name="ctroop" type="text" id="ctroop" size="6" maxlength="3">
                </div></td>
              </tr>
              <tr>
                <td colspan=3 align=center><input name="train" type="submit" id="train" value="Train"></td>
              </tr>
            </table>
              </form>
		  <Br>
		  <form name="form2" method="post" action="">
            <table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_lines">
              <tr>
                <th scope="col" colspan=3>Rehibilitation Center </th>
              </tr>
              <tr>
                <td>Troop name </td>
                <td>Cost</td>
                <td>Amount</td>
              </tr>
              <tr>
                <td>Assault Trooper </td>
                <td>0 Naquadah </td>
                <td><div align="center">
                  <input name="atroop" type="text" id="atroop" size="6" maxlength="3">
                </div></td>
              </tr>
              <tr>
                <td>Gaurd</td>
                <td>0 Naquadah </td>
                <td><div align="center">
                  <input name="dtroop" type="text" id="dtroop" size="6" maxlength="3">
                </div></td>
              </tr>
              <tr>
                <td>Covert Operative </td>
                <td>0 Naquadah </td>
                <td><div align="center">
                  <input name="ctroop" type="text" id="ctroop" size="6" maxlength="3">
                </div></td>
              </tr>
              <tr>
                <td colspan=3 align=center><label>
                  <input name="untrain" type="submit" id="untrain" value="Rehibilitate">
                </label></td>
              </tr>
            </table>
              </form>
          </td>
      </tr>
    </table> 
<br>
<table width="100%" border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td width=50%><table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_lines">
          <tr>
            <th><div align="center">Covert Level </div></th>
          </tr>
          <tr align=center>
          
              <form name="form3" method="post" action=""> <td>
                
                  Current: <?php echo(number_format($user['covertLVL'])); ?> 
                  <input name="spylvl" type="submit" id="spylvl" value="Upgrade For <?php echo(number_format($spycost)); ?>">
              </td>    
              </form>
             
          </tr>
        </table></td>
        <td><table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_lines">
          <tr>
            <th scope="col">Birth Rate </th>
          </tr>
          <tr align=center>
          <form name="form" method="post" action="">  <td><div align="center">Current: <?php echo(number_format($user['birthrate'])); ?> 
                <label>
                <input name="birthamt" type="text" id="birthamt" value="0" size="6" maxlength="2">
                </label>
                <input name="birthlvl" type="submit" id="birthlvl" value="Upgrade For <?php echo(number_format($birthcost)); ?>">
            </div></td></form>
          </tr>
        </table></td>
      </tr>
    </table></td></tr></Table><br>
  <?php include("includes/bottom.php"); ?>
</center>
</body>
</html>

 

any help would be awsome!

 

~Dethman~

Link to comment
Share on other sites

 

Warning: Missing argument 5 for traintroops() in /home2/gt/public_html/functions/train2.php on line 14

 

Warning: Missing argument 6 for traintroops() in /home2/gt/public_html/functions/train2.php on line 14

 

These 2 lines are saying that your not passing arguments 5 and 6 on line 14 of train2.php

 

This can be stopped by setting error reporting to a higher level.

 

The header error is because your sending output to the browser before you call the header function. It looks like the error above is actually the output here, though I may be wrong.

 

set error reporting to E_ERROR and see what that does.

 

Nate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.