Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
script variable doesnt work
Old 11-22-2006, 12:35 PM script variable doesnt work
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
i made this script but when i add some text into the textbox then click buy it inserts nothing into the database when i want it to insert tge number entered into the textbox.

PHP Code:
<?php
include("**");
include(
"**");
?>
<?php 
if ($action == 'buy')
{
$weapon11 $_POST['weapon1'];
$weapon111 $weapon11;
$sql mysql_query ("UPDATE `user_weapons` SET `Machine Gun` = '$weapon111' WHERE `username` = '$session->username' LIMIT 1");
mysql_query($sql);
}
?>
<html>
<head>
<title>ARMORY</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p><strong><font size="7">Armory</font></strong></p>
<p><?php
$resultconfig2 
= @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$cash4 number_format($cash3);
echo 
"You have $cash4 to spend.";
?>
<p>
  
<table width="62%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="157"><div align="center"><strong>Weapon</strong></div></td>
    <td width="76"><div align="center"><strong>Strength</strong></div></td>
    <td width="66"><div align="center"><strong>Cost</strong></div></td>
    <td width="85"><div align="center"><strong>You Have</strong></div></td>
    <td width="56"><div align="center"><strong>Max</strong></div></td>
    <td width="36"><div align="center"><strong>Buy </strong></div></td>
  </tr>
  <tr> 
    <td>Machine Gun</td>
    <td>100</td>
    <td>500</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 500) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?>
</td><td width="36"><form name="weapon1" method="post" action="/armory.php?action=buy">
        <input name="weapon1" type="text" id="weapon1" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>EMP Cannon</td>
    <td>500</td>
    <td>25,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 25000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon2" type="text" id="weapon2" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Ion Cannon</td>
    <td>900</td>
    <td>45,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 45000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon3" type="text" id="weapon3" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Molecular Disruptor</td>
    <td>2500</td>
    <td>125,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 125000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon4" type="text" id="weapon4" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Mass Projectile Cannon</td>
    <td>5000</td>
    <td>250,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 250000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon5" type="text" id="weapon5" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Mass Driver Cannon</td>
    <td>5500</td>
    <td>275,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 275000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon6" type="text" id="weapon6" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Special Rift Generator</td>
    <td>7000</td>
    <td>350,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 350000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon7" type="text" id="weapon7" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Cosmic Energy Enhancer</td>
    <td>14,000</td>
    <td>750,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 750000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon8" type="text" id="weapon8" size="5">
      </form></td>
  </tr>
  <tr> 
    <td>Nuclear Time Bomb</td>
    <td>20,000</td>
    <td>1,000,000</td>
    <td>&nbsp;</td>
    <td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1"); 
$row2 mysql_fetch_row($resultconfig2);
$cash3 =  $row2['0'];
$totalweapons = ($cash3 1000000) - 1;
$totalweapons2 number_format($totalweapons);
echo 
"$totalweapons2";
?></td>
    <td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
        <input name="weapon9" type="text" id="weapon9" size="5">
      </form></td>
  </tr>
</table>
<table width="62%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="right">
        <form name="form2" method="post" action="/armory.php?action=buy">
          <input name="buy" type="submit" id="buy" value="Buy">
        </form>
      </div></td>
  </tr>
</table>
</body>
</html>
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 06-14-2007, 01:55 PM Re: script variable doesnt work
Skilled Talker

Latest Blog Post:
My book update
Posts: 97
Name: Eric
Location: Las Vegas
Trades: 0
each form needs to have it's own name. you should look into looping in php. it will make you life much easier
__________________

Please login or register to view this content. Registration is FREE

Eric - M
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
peanutpad is offline
Reply With Quote
View Public Profile Visit peanutpad's homepage!
 
Reply     « Reply to script variable doesnt work
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67349 seconds with 12 queries