Jump to content

getting undefined index error


shwetapandit

Recommended Posts

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

i am getting a notice as undefined index on line 7

That 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.