Monk3h Posted April 8, 2008 Share Posted April 8, 2008 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]"); }}} Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/ Share on other sites More sharing options...
darkfreaks Posted April 8, 2008 Share Posted April 8, 2008 <?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']"); }}} ?> Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512471 Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 That Brings back an error, its not any combination of adding or removing ' iv already tried that.. :/ Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512473 Share on other sites More sharing options...
darkfreaks Posted April 8, 2008 Share Posted April 8, 2008 what was the error ??? Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512474 Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/monk3h/public_html/troops.php on line 50 Line 50: Print "You Bought $aunit $unit1['name'] for Your tribe at a cost of $amm1 Credits"; Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512476 Share on other sites More sharing options...
darkfreaks Posted April 8, 2008 Share Posted April 8, 2008 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']"); }}} ?> Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512477 Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/monk3h/public_html/troops.php on line 55 Line 55: mysql_query("update tribes set credits=credits-$amm1 where id=$mytribe['id']"); Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512478 Share on other sites More sharing options...
darkfreaks Posted April 8, 2008 Share Posted April 8, 2008 <?php mysql_query('update tribes set credits=credits-$amm1 where id='$mytribe['id']');?> Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512482 Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512485 Share on other sites More sharing options...
darkfreaks Posted April 8, 2008 Share Posted April 8, 2008 hmmmm add ini_set('error_reporting',E_ALL); see if you get an error Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512490 Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/100223-step-not-working/#findComment-512492 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.