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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.