shwetapandit Posted August 1, 2013 Share Posted August 1, 2013 i am getting a notice as undefined index on line 7 which is blue colored and then below notice it shows Unknown column 'c.id' in 'field list'.my script is not working. plz suggest me the way i correct this.i am attaching the complete script in attachment.showitem.php //connect to database $mysqli = mysqli_connect("localhost", "root", "", "storefront"); $display_block = "<h1>My Store - Item Detail</h1>"; //create safe values for use $safe_item_id = mysqli_real_escape_string($mysqli, $_GET['item_id']); //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 = '".$safe_item_id."'"; Link to comment https://forums.phpfreaks.com/topic/280713-getting-undefined-index-error/ Share on other sites More sharing options...
trq Posted August 1, 2013 Share Posted August 1, 2013 Does $_GET['item_id'] exist? Link to comment https://forums.phpfreaks.com/topic/280713-getting-undefined-index-error/#findComment-1442954 Share on other sites More sharing options...
shwetapandit Posted August 1, 2013 Author Share Posted August 1, 2013 yes item_id exists. Link to comment https://forums.phpfreaks.com/topic/280713-getting-undefined-index-error/#findComment-1442994 Share on other sites More sharing options...
DavidAM Posted August 1, 2013 Share Posted August 1, 2013 i am getting a notice as undefined index on line 7That is an indication that there is no "item_id" parameter provided in the URL (for $_GET). then below notice it shows Unknown column 'c.id' in 'field list'That indicates (based on your query) that there is no column named id in the store_categories table Check the spelling and cAsE in both cases. If the page might be requested without an item_id, then check for it before doing the query and take some appropriate action when it is not present. Hint: Any publicly available page might be requested without the expected url parameters. Link to comment https://forums.phpfreaks.com/topic/280713-getting-undefined-index-error/#findComment-1443004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.