it gets a parse error on line 120 and on line 120 i got "nothing" the code ends at line 119 so i know i got a php faul somewhere i just cant figure out where plz help and ohhh thanks for ya help
This code should work shouldn´t it?
all is one page of code just striped it down for easy readings
Code: Select all
<?php
// Get the database connector stuff
include "../login/database.php";
// Build our query
$sql1 = 'SELECT * FROM `infantries`';
// Get the result if there is one
// DO NOT die() IN PRODUCTION!!!
if (!$result1 = mysql_query($sql1))
{
die('The query<br /><strong>' . $sql1 . '</strong><br />failed:<br />' . mysql_error());
}
?>
Code: Select all
<?php
$id =(isset($_GET['saved_id'])) ? (int)$_GET['saved_id'] : false;
if($id !== false) {
$sql="SELECT * FROM konto WHERE saved_id=$id"; //selecting all from DB "Konto" where saved_id is the same as in the array $id
}
else
{
echo "NO saved_id!";
}
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
$my['Swordmen'] = $row['swordmen'];
$my['Macemen'] = $row['macemen'];
$my['Pikemen'] = $row['pikemen'];
if(isset($_POST['Swordmen']))
{
// the Swordmen Buy button was clicked
$unit = "Swordmen";
$qty = $_POST['qty_Swordmen'];
$sql="UPDATE konto SET swordmen='".$_POST[qty_swordmen]."' WHERE $id=saved_id";//Sätt upp SQL fråga.
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tabell.
}
if(isset($_POST['Macemen']))
{
// the Macemen Buy button was clicked
$unit = "Macemen";
$qty = $_POST['qty_Macemen'];
$sql="UPDATE konto SET macemen='".$_POST[qty_macemen]."' WHERE $id=saved_id";//Sätt upp SQL fråga.
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tabell.
}
if(isset($_POST['Pikeman']))
{
// the Pikeman Buy button was clicked - so you need to use qty_Pikemen
$unit = "Pikeman";
$qty = $_POST['qty_Pikemen'];
$sql="UPDATE konto SET pikemen='".$_POST[qty_pikemen]."' WHERE $id=saved_id";//Sätt upp SQL fråga.
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tabell.
}
}
?>
Code: Select all
}
?>
<html>
<head>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<title>Infantrie</title>
</head>
<body bgcolor="#A4A8B0">
<style type="text/css"> <!--selecting the style type-->
<!--
a:link {text-decoration: none; color: black}
a:visited {text-decoration: none; color: black}
a:active {text-decoration: none; color: black}
a:visited {text-decoration: none; color: black}
.textbox { background-color: #DEB887; }
.submit { background-color: #DEB887; }
-->
</style> <!--ending the style type-->
Code: Select all
<p>
Är du villig att köpa soldater? Tror du att du är man nog att göra det?
</p>
<table border="1">
<tr>
<th>Units</th>
<th>AtkArm</th>
<th>Buyfor</th>
<th>Sellfor</th>
<th>You Own</th>
<th>Buy</th>
</tr>
<?php while ($row1 = mysql_fetch_assoc($result1)): ?>
<tr>
<th><?php echo $row1['Units'] ;?></th>
<th><?php echo $row1['AtkHp'] ;?></th>
<th><?php echo $row1['Buyfor'] ;?></th>
<th><?php echo $row1['Sellfor'] ;?></th>
<th><?php echo $my[$row1['Units']]; ?></th>
<th>
<font color="black" valign= "top"><input style='width:45;height:20' type="text" name="<?php echo $my[$row1['Units']]; ?>" size="250" class="textbox" value=""></font>
<input style='width:45;height:30;font-weight:bold' name="<?php echo $my[$row1['Units']]; ?>" type="submit" class="submit" value="Buy!">
</th>
</tr>
<?php endwhile; ?>
</table>
</html>