-3

This is the error:

Notice: Undefined index: $product_title in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 148

Notice: Undefined index: $product_cat in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 149

Notice: Undefined index: $product_brand in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 150

Notice: Undefined index: $product_price in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 151

Notice: Undefined index: $product_desc in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 152

Notice: Undefined index: $product_keywords in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 153

Notice: Undefined index: $product_image in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 156

Notice: Undefined index: $product_image in C:\xampp\htdocs\MyShop\admin_area\insert_product.php on line 157 insert into products (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values ('','','','','','','')

This is the code:

if(isset($_POST['insert_post'])){
    $product_title = $_POST['$product_title'];
    $product_cat = $_POST['$product_cat'];
    $product_brand = $_POST['$product_brand'];
    $product_price = $_POST['$product_price'];
    $product_desc = $_POST['$product_desc'];
    $product_keywords = $_POST['$product_keywords'];

    $product_image = $_FILES['$product_image']['name'];
    $product_image_tmp = $_FILES['$product_image']['tmp_name'];

     echo $insert_product = "insert into products 
     (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values ('$product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','$product_keywords')";
}
JJJ
  • 32,902
  • 20
  • 89
  • 102
sameer
  • 1
  • 1
  • possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Rizier123 Feb 27 '15 at 09:43
  • Notice: Undefined index: $source_code in question - nah, seriously, did you forget to attach your code to the question? – phpPhil Feb 27 '15 at 09:46

1 Answers1

0

It seems to be, you are using an array with $product_image as array key, but ther is no array key $product_image.

1) try

if(array_key_exists($product_image,$array)){
   // code in the error-lines (148,149,150, .....
}
SbstnErb
  • 101
  • 1
  • 8