Jump to content

Recommended Posts

For some reason when i click the Buy button it goes to the troops.php?step=unit1 URL but Nothing Happends :(

 

Here is a snipit of the code..

 

if ($mytribe[devcount] >=1){


Print"<form method=post action=troops.php?step=unit1>
<table>
<tr>
    <td><center>$unit1[name]</center></td>
    <td><center>$unit1[cost] Credits</center></td>
    <td><center><input type=text name=aunit1></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit1[description]</i></center></td>
  </tr>
</table>";

if (step == unit1){
$amm1 = ($unit1[cost]*$aunit);
if ($mytribe[credits] < $amm1){


Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1[name] for Your tribe at a cost of $amm1 Credits";


mysql_query("update tribes set credits=credits-$amm1 where id=$mytribe[id]");
mysql_query("update tribes set unit1=unit1+$aunit1 where id=$mytribe[id]");

}}}

Link to comment
https://forums.phpfreaks.com/topic/100223-step-not-working/
Share on other sites

<?php

if ($mytribe['devcount'] >=1){


Print"<form method=post action=troops.php?step=unit1>
<table>
<tr>
    <td><center>$unit1[name]</center></td>
    <td><center>$unit1[cost] Credits</center></td>
    <td><center><input type=text name=aunit1></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit1[description]</i></center></td>
  </tr>
</table>";

if (step == "unit1"){
$amm1 = ($unit1['cost']*$aunit);
if ($mytribe['credits'] < $amm1){


Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1['name'] for Your tribe at a cost of $amm1 Credits";


mysql_query("update tribes set credits=credits-$amm1 where id=$mytribe['id']");
mysql_query("update tribes set unit1=unit1+$aunit1 where id=$mytribe['id']");

}}}
?>

Link to comment
https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512471
Share on other sites

put it inside a variable prior to echoing it.

 

 

<?php

if ($mytribe['devcount'] >=1){


Print"<form method=post action=troops.php?step=unit1>
<table>
<tr>
    <td><center>$unit1[name]</center></td>
    <td><center>$unit1[cost] Credits</center></td>
    <td><center><input type=text name=aunit1></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit1[description]</i></center></td>
  </tr>
</table>";

if (step == "unit1"){
$amm1 = ($unit1['cost']*$aunit);
if ($mytribe['credits'] < $amm1){


Print "Your Tribe Does not have that many Credits.";

}else{

$unit2= $unit1['name'] ;

Print "You Bought $aunit $unit2 for Your tribe at a cost of $amm1 Credits";


mysql_query("update tribes set credits=credits-$amm1 where id=$mytribe['id']");
mysql_query("update tribes set unit1=unit1+$aunit1 where id=$mytribe['id']");

}}}
?>

Link to comment
https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512477
Share on other sites

Parse error: syntax error, unexpected T_VARIABLE in /home/monk3h/public_html/troops.php on line 55

 

 

 

 

 

Edit: This is a copy of the script before any Errors Apeared.. It just wouldnt Perform ?step

 

<?php $title = "Troops"; include("header.php"); ?>

<?php
$mytribe = mysql_fetch_array(mysql_query("select * from tribes where id=$stat[tribe]"));
$devcount = mysql_fetch_array(mysql_query("select * from dev where id=$mytribe[devcount]+1"));
$unit1 = mysql_fetch_array(mysql_query("select * from troops where id=1"));
$unit2 = mysql_fetch_array(mysql_query("select * from troops where id=2"));
$unit3 = mysql_fetch_array(mysql_query("select * from troops where id=3"));
$unit4 = mysql_fetch_array(mysql_query("select * from troops where id=4"));

Print "Here are all the Offensive and Defensive units your tribe has currently Developed..<br><br>ATTENTION! All Hail <b>$mytribe[name]!</b><br><br>";
Print"
<table width=95% border=0>
  <tr>
    <td><center><b>Name</b></center></td>
    <td><center><b>Cost</b></center></td>
    <td><center><b>Amount</b></center></td>
    <td><center><b>Buy</b></center></td>
  </tr>
  <tr>
    <td colspan=4><center><b>Description</b></center></td>
  </tr>
</table><br><br>";

if ($mytribe[devcount] >=1){


Print"<form method=post action=troops.php?step=unit1>
<table>
<tr>
    <td><center>$unit1[name]</center></td>
    <td><center>$unit1[cost] Credits</center></td>
    <td><center><input type=text name=aunit1></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit1[description]</i></center></td>
  </tr>
</table>";

if (step == unit1){
$amm1 = ($unit1[cost]*$aunit);
if ($mytribe[credits] < $amm1){


Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1[name] for Your tribe at a cost of $amm1 Credits";


mysql_query("update tribes set credits=credits-$amm1 where id=$mytribe[id]");
mysql_query("update tribes set unit1=unit1+$aunit1 where id=$mytribe[id]");

}}}



if ($mytribe[devcount] >=2){


Print"<form method=post action=troops.php?step=unit2>
<table>
<tr>
    <td><center>$unit2[name]</center></td>
    <td><center>$unit2[cost] Credits</center></td>
    <td><center><input type=text name=aunit2></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit2[description]</i></center></td>
  </tr>
</table>";


if (step == unit2){
$amm2 = ($unit1[cost]*$aunit);
if ($mytribe[credits] < $amm2){

Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1[name] for Your tribe at a cost of $amm1";

mysql_query("update tribes set credits=credits-$amm2 where id=$mytribe[id]");
mysql_query("update tribes set unit2=unit2+$aunit2 where id=$mytribe[id]");

}}}



if ($mytribe[devcount] >=3){


Print"<form method=post action=troops.php?step=unit3>
<table>
<tr>
    <td><center>$unit3[name]</center></td>
    <td><center>$unit3[cost] Credits</center></td>
    <td><center><input type=text name=aunit3></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit3[description]</i></center></td>
  </tr>
</table>";


if (step == unit3){
$amm3 = ($unit1[cost]*$aunit);
if ($mytribe[credits] < $amm3){

Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1[name] for Your tribe at a cost of $amm1";

mysql_query("update tribes set credits=credits-$amm3 where id=$mytribe[id]");
mysql_query("update tribes set unit3=unit3+$aunit3 where id=$mytribe[id]");

}}}




if ($mytribe[devcount] >=4){


Print"<form method=post action=troops.php?step=unit4>
<table>
<tr>
    <td><center>$unit4[name]</center></td>
    <td><center>$unit4[cost] Credits</center></td>
    <td><center><input type=text name=aunit4></b></center></td>
    <td><center><input type=submit value=Buy></form></center></td>
  </tr>
  <tr>
    <td colspan=4><center><i>$unit4[description]</i></center></td>
  </tr>
</table>";


if (step == unit4){
$amm4 = ($unit1[cost]*$aunit);
if ($mytribe[credits] < $amm4){

Print "Your Tribe Does not have that many Credits.";

}else{

Print "You Bought $aunit $unit1[name] for Your tribe at a cost of $amm1";

mysql_query("update tribes set credits=credits-$amm4 where id=$mytribe[id]");
mysql_query("update tribes set unit4=unit4+$aunit4 where id=$mytribe[id]");

}}}


?>

<?php include("footer.php"); ?>

Link to comment
https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512485
Share on other sites

Notice: Use of undefined constant step - assumed 'step' in /home/monk3h/public_html/troops.php on line 42

 

Notice: Use of undefined constant unit1 - assumed 'unit1' in /home/monk3h/public_html/troops.php on line 42

 

Notice: Use of undefined constant devcount - assumed 'devcount' in /home/monk3h/public_html/troops.php on line 61

 

Notice: Use of undefined constant step - assumed 'step' in /home/monk3h/public_html/troops.php on line 78

 

Notice: Use of undefined constant unit2 - assumed 'unit2' in /home/monk3h/public_html/troops.php on line 78

 

Notice: Use of undefined constant devcount - assumed 'devcount' in /home/monk3h/public_html/troops.php on line 95

 

Notice: Use of undefined constant step - assumed 'step' in /home/monk3h/public_html/troops.php on line 112

 

Notice: Use of undefined constant unit3 - assumed 'unit3' in /home/monk3h/public_html/troops.php on line 112

 

Notice: Use of undefined constant devcount - assumed 'devcount' in /home/monk3h/public_html/troops.php on line 130

Link to comment
https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512492
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.