PHP koden hvor der er fejl er denne:
<?php
session_start();
//etablerer forbindelse til databasen
$conn = mysql_connect("XXX", "XXX", "XXX")
or die(mysql_error());
mysql_select_db("michell_varelager",$conn) or die(mysql_error());
$display_block = "<h1>Detaljer om varen</h1>";
//validering af varen
$get_items = "SELECT c.name, si.name, si.price, si.description, si.picture FROM inventory AS si left join category AS c ON c.id = si.category WHERE si.id = ".$_GET['item_id']."";
$get_items_res = mysql_query($get_items)
or die (mysql_error());
if (mysql_num_rows($get_items_res) <1) {
//varen ikke valid
$display_block .= "<P><em>Invalid vare valg</em></p>";
} else {
//varen ok, hent oplysninger
$name = strtoupper(stripslashes(mysql_result($get_items_res,0,'name')));
$price = mysql_result($get_items_res,0,'price');
$description = stripslashes(mysql_result($get_items_res,0,'description'));
$picture = mysql_result($get_items_res,0,'picture');
//Lav et "brødkrummespor"
$display_block .= "<P><strong><em>Du ser på:</em><br/>> ".$name."</strong></p> <table cellpadding=3 cellspacing=3> <tr> <td valign=middle align=center><img src=\"".$picture."\"> </td> <td valign=middle><P><strong>Beskrivelse:</strong><br>".$description."</p><P><strong>Pris:</strong> kr. ".$price."</p><form method=post action=\"addtocart.php\">";
//hent størrelser
$get_sizes = "SELECT item_size FROM store_item_size where item_id = ".$_GET['item_id']." ORDER BY item_size";
$get_sizes_res = mysql_query($get_sizes)
or die(mysql_error());
if (mysql_num_rows($get_sizes_res) > 0) {
$display_block .= "<P><strong>Findes i størrelserne og farverne: </strong><select name=\"sel_item_size\" onchange=\"javascript:document.Size.submit();\">";
while ($sizes = mysql_fetch_array($get_sizes_res)) {
$item_size = $sizes['item_size'];
$display_block .= "<option value=\"".$item_size."\">".$item_size."</option>";
}
$display_block .= "</select>";
}
//hent antal
$get_qty = "SELECT store_item_qty FROM store_item_size where item_id = ".$_GET['item_id']." ORDER BY store_item_qty";
$get_qty_res = mysql_query($get_qty)
or die(mysql_error());
if (mysql_num_rows($get_qty_res) > 0) {
$display_block .= "<P><strong>Antal: </strong><select name=\"sel_item_qty\" onchange=\"javascript:document.Size.submit();\">";
while ($qty = mysql_fetch_array($get_qty_res)) {
$store_item_qty = $qty['store_item_qty'];
$display_block .= "<option value=\"".$store_item_qty."\">".$store_item_qty."</option>";
for ($i=1; $i<$qty['store_item_qty']; $i++) {
$display_block .= "<option value=\"".$i."\">".$i."</option>";
}
}
$display_block .= "</select>";
}
$display_block .= "</select><input type=\"hidden\" name=\"sel_item_id\" value=\"".$_GET['item_id']."\"><P><input type=\"submit\" name=\"submit\" value=\"Tilføj til indkøbsvognen\"></p></form></td></tr></table>";
}
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="rullepanel.css">
<style>
a {text-decoration: none}
</style>
</head>
<body>
<? print $display_block; ?>
</body>
</html>