Hi All,
I am having an undefined index error when I preview my code and have had a look at the code over and over again, but still cannot identify my error. Could someone look at it for me please?
This is the code for my page.
This is the error that I am getting.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Online storefront: Just for baseball lovers.</title> </head> <body> <?php //database connection $mysqli = mysqli_connect('localhost','root','', 'eshop'); $display_block = "<h1>Online store for baseball enthusiasts</h1>"; //validate item $get_item_sql = "SELECT c.id as cat_id, c.cat_title, si.item_title, si.item_price, si.item_desc, si.item_image FROM store_items AS si LEFT JOIN store_categories AS c on c.id = si.cat_id WHERE si.id = '".$_GET["item_id"]."'"; //here we display the result $get_item_res = mysqli_query($mysqli, $get_item_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_item_res) < 1) { //invalid item $display_block .= "<p><em>Invalid item selction.</em></p>"; } else { //valid item, get info while ($item_info = mysqli_fetch_array($get_item_res)) { $cat_id = $item_info['cat_id']; $cat_title = strtoupper(stripslashes($item_info['cat_title'])); $item_title = stripslashes($item_info['item_title']); $item_price = $item_info['item_price']; $item_desc = stripslashes($item_info['item_desc']); $item_image = $item_info['item_image']; } //here make breadcrumb trail $display_block .= "<p><strong><em>You are viewing:</em><br/> <a href=\"seestore.php?cat_id=".$cat_id."\">".$cat_title."</a>> ".$item_title."</strong></p> <table cellpadding=\"3\" cellspacing=\"3\"> <tr> <td valign=\"middle\" align=\"center\"> <img src=\"".$item_image."\"/></td> <td valign=\"middle\"><p><strong>Description:</strong><br/>". $item_desc."</p> <p><strong>Price:</strong> \$".$item_price."</p>"; //free result mysqli_free_result($get_item_res); //get colors $get_colors_sql = "SELECT item_color FROM store_item_color WHERE item_id = '".$_GET["item_id"]."' ORDER BY item_color"; //now show the results for get color $get_color_res = mysqli_query($mysqli, $get_colors_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_colors_res) > 0) { $display_block .= "<p><strong>Available Colors:</strong><br/>"; while ($colors = mysqli_fetch_array($get_colors_res)) { $item_color = $colors['item_color']; $display_block .= $item_color."<br/>"; } } //free result mysqli_free_result($get_color); //get sizes $get_sizes_sql = "SELECT item_size FROM store_item_size WHERE item_id = ".$_GET["item_id"]." ORDER BY item_size"; //we show the rsult get sizes below $get_sizes_res = mysqli_query($mysqli,$get_sizes_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_sizes_res) > 0) { $display_block .= "<p><strong>Available Sizes:</strong><br/>"; while ($sizes = mysqli_fetch_array($get_sizes_res)) { $item_size = $sizes['item_size']; $display_block .= $item_size."<br/>"; } } //free result mysqli_free_result($get_sizes_res); $display_block .= " </td> </tr> </table>"; } ?> <?php echo $display_block;?> </body> </html>
I will appreciate some help please.Code:Notice: Undefined index: item_id in C:\xampp\htdocs\store\showitem.php on line 16 Online store for baseball enthusiasts Invalid item selction.
Thanks,
Menre




Reply With Quote