Welcome Guest, Not a member yet? Register   Sign In
A PHP Error was encountered Severity: Notice Message: Undefined index:
#3

Hi Dave,

thank you for your response, I've search through the controller file and the information in my opinion is correct I can't see where I have missed changing a name, I simply coppied it from the relevant code and pasted it back in and then changed from accessories_pdf_file to accessories_fitting_pdf_file,
I've been staring at the same bits of code for a day and a half now,

This is the code for the controller

and this is the page http://www.ohm.co.uk/accessories/lwb-pt
were the fault is occurring.

I appreciate any help thank you.


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Accessories extends CI_Controller {

    function 
__construct()
    {
        
parent::__construct();
        
$this->load->model('accessoriesmodel','',TRUE);
    }
 
    function 
index()
    {
        if(!empty(
$_SESSION["webadmin"]))
        {
            
$this->load->view('template/header.php');
            
$this->load->view('accessories/accessoriesList');
            
$this->load->view('template/footer.php');
        }
        else
        {
            
//If no session, redirect to login page
            
redirect('login''refresh');
        }
    }

    function 
fetch()
    {    
        
$get_result $this->accessoriesmodel->getRecords($_GET);
        
        
$result = array();
        
$result["sEcho"]= $_GET['sEcho'];
        
        
$result["iTotalRecords"] = isset($get_result['totalRecords']) ? $get_result['totalRecords'] : 0;                                    
        
$result["iTotalDisplayRecords"]= isset($get_result['totalRecords']) ? $get_result['totalRecords'] : 0;                            
        
        
$items = array();
        
        for(
$i=0;$i<sizeof($get_result['query_result']);$i++){
            
$temp = array();
            
$actionCol "";
            
$status "";
            
array_push($temp$get_result['query_result'][$i]->accessories_name);
             
            
$status strtolower($get_result['query_result'][$i]->status) == strtolower('active') ? '<font color="green">Active</font>''<font color="red">Inactive</font>';
            
array_push($temp$status);
            
            
$actionCol .='<a href="accessories/addEdit?text='.rtrim(strtr(base64_encode("id=".$get_result['query_result'][$i]->accessories_id), '+/''-_'), '=').'" title="Edit"><i class="icon-picture icon-edit"></i></a>';
            
$actionCol .='&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteData(\''.$get_result['query_result'][$i]->accessories_id.'\');" title="Delete"><i class="icon-remove-sign"></i></a>';
            
array_push($temp$actionCol);
            
            
array_push($items$temp);
        }
        
        
$result["aaData"] = $items;
        echo 
json_encode($result);
        exit;
    }
 
    function 
addEdit()
    {
        if(!empty(
$_SESSION["webadmin"]))
        {
            
$accessories_id "";
            if(!empty(
$_GET['text']) && isset($_GET['text'])){
                
$varr=base64_decode(strtr($_GET['text'], '-_''+/'));    
                
parse_str($varr,$url_prams);
                
$accessories_id $url_prams['id'];
            }
            
            
$result "";
            
            if(!empty(
$accessories_id))
            {
                
$result['recorddata'] = $this->accessoriesmodel->getFormdata($accessories_id);
                
$condition "accessories_id = '".$accessories_id."' ";
                
$result['accessories_images'] = $this->accessoriesmodel->getData("tbl_accessories_images",$accessories_id);
            }
            
            
//echo "<pre>";
            //print_r($result);
            //exit;
            
$this->load->view('template/header.php');
            
$this->load->view('accessories/index',$result);
            
$this->load->view('template/footer.php');
        }
        else
        {
            
redirect('login''refresh');
        }
     }
             
     function 
submitForm()
     {
         
//echo "<pre>";
         //print_r($_POST);
        // print_r($_FILES);
        // exit;
            
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
            {
                if(empty(
$_POST['accessories_name']))
                {
                    echo 
json_encode(array("success"=>false,"msg"=>"Please enter accessories name.."));
                    exit;
                }
                
                
$chk_condition "accessories_name = '".trim($_POST['accessories_name'])."'";
                if(!empty(
$_POST['accessories_id']))
                {
                    
$chk_condition .= " AND accessories_id != ".$_POST['accessories_id']." ";
                }
                
                
$chk_result $this->accessoriesmodel->getData("tbl_accessories_master",$chk_condition);
                
//print_r($chk_result)."gfhfgshgf";
                //echo "</br>".$chk_condition;
                //exit;
                
if(!empty($chk_result[0]['accessories_name']))
                {
                    echo 
json_encode(array("success"=>false,"msg"=>"Record Already Exist.."));
                    exit;
                }
                
                
$data = array();
                
$data['accessories_name'] = $_POST['accessories_name'];
                
$accessories_link = (str_replace(' ''-'strtolower(trim($_POST['accessories_name']))));
                
$data['link'] = $accessories_link;
                
//$data['accessories_image'] = $thumnail_value;
                
$data['accessories_description'   htmlentities($_POST['accessories_description']);
                
                
//banner image
                
if(isset($_FILES) && isset($_FILES["accessories_banner_image"]["name"]))
                {
                    if(!empty(
$_POST['accessories_id']))
                    {
                        
$prev_banner $this->accessoriesmodel->getFormdata($_POST['accessories_id']);
                        if(!empty(
$prev_banner[0]->accessories_banner_image))
                        {
                            
$prev_banner_path DOC_ROOT_FRONT."/images/accessories_images/".$prev_banner[0]->accessories_banner_image;
                            if(
file_exists($prev_banner_path))
                            {
                                
unlink($prev_banner_path);
                            }
                        }
                    }
                    
                    
$this->load->library('upload');
                    
                    
$config = array();
                    
$config['upload_path'] = DOC_ROOT_FRONT."/images/accessories_images/";
                    
$config['max_size'      '1000000';
                    
$config['allowed_types'] = 'gif|jpg|png';
                    
//$config['file_name']     = md5(uniqid("100_ID", true));
                    
                    
$this->upload->initialize($config);
                    
                    if (!
$this->upload->do_upload("accessories_banner_image"))
                    {
                        
$image_error = array('error' => $this->upload->display_errors());
                        echo 
json_encode(array("success"=>false,"msg"=>$image_error['error']));
                        exit;
                    }
                    else
                    {
                        
$image_data = array('upload_data' => $this->upload->data());
                        
$data['accessories_banner_image'] = $image_data['upload_data']['file_name'];
                    }
                }
                else
                {
                    
$data['accessories_banner_image'] = $_POST['input_accessories_banner_image'];
                }
                
                
                
//pdf file
                
if(isset($_FILES) && isset($_FILES["accessories_pdf_file"]["name"]))
                {
                    
                    if(!empty(
$_POST['accessories_id']))
                    {
                        
$prev_pdf $this->accessoriesmodel->getFormdata($_POST['accessories_id']);
                        if(!empty(
$prev_pdf[0]->accessories_pdf_file))
                        {
                            
$prev_pdf_path DOC_ROOT_FRONT."/images/accessories_images/pdf/".$prev_pdf[0]->accessories_pdf_file;
                            if(
file_exists($prev_pdf_path))
                            {
                                
unlink($prev_pdf_path);
                            }
                        }
                    }
                    
                    
$this->load->library('upload');
                    
                    
$config = array();
                    
$config['upload_path'] = DOC_ROOT_FRONT."/images/accessories_images/pdf/";
                    
$config['max_size'      '1000000';
                    
$config['allowed_types'] = 'pdf';
                    
//$config['file_name']     = md5(uniqid("100_ID", true));
                
                    
$this->upload->initialize($config);
                    
                    if (!
$this->upload->do_upload("accessories_pdf_file"))
                    {
                        
$image_error = array('error' => $this->upload->display_errors());
                        echo 
json_encode(array("success"=>false,"msg"=>$image_error['error']));
                        exit;
                    }
                    else
                    {
                        
$image_data = array('upload_data' => $this->upload->data());
                        
$data['accessories_pdf_file'] = $image_data['upload_data']['file_name'];
                    }
                }
                else
                {
                    
$data['accessories_pdf_file'] = $_POST['input_accessories_pdf_file'];
                }
                
                
//pdf file
                
if(isset($_FILES) && isset($_FILES["accessories_zip_file"]["name"]))
                {
                    
                    if(!empty(
$_POST['accessories_id']))
                    {
                        
$prev_zip $this->accessoriesmodel->getFormdata($_POST['accessories_id']);
                        if(!empty(
$prev_zip[0]->accessories_zip_file))
                        {
                            
$prev_zip_path DOC_ROOT_FRONT."/images/accessories_images/zip/".$prev_zip[0]->accessories_zip_file;
                            if(
file_exists($prev_zip_path))
                            {
                                
unlink($prev_zip_path);
                            }
                        }
                    }
                    
                    
$this->load->library('upload');
                    
                    
$config = array();
                    
$config['upload_path'] = DOC_ROOT_FRONT."/images/accessories_images/zip/";
                    
$config['max_size'      '1000000';
                    
$config['allowed_types'] = 'zip';
                    
//$config['file_name']     = md5(uniqid("100_ID", true));
                
                    
$this->upload->initialize($config);
                    
                    if (!
$this->upload->do_upload("accessories_zip_file"))
                    {
                        
$image_error = array('error' => $this->upload->display_errors());
                        echo 
json_encode(array("success"=>false,"msg"=>$image_error['error']));
                        exit;
                    }
                    else
                    {
                        
$image_data = array('upload_data' => $this->upload->data());
                        
$data['accessories_zip_file'] = $image_data['upload_data']['file_name'];
                    }
                }
                else
                {
                    
$data['accessories_zip_file'] = $_POST['input_accessories_zip_file'];
                }
                                
//pdf file
                
if(isset($_FILES) && isset($_FILES["accessories_fitting_pdf_file"]["name"]))
                {
                    
                    if(!empty(
$_POST['accessories_id']))
                    {
                        
$prev_pdf $this->accessoriesmodel->getFormdata($_POST['accessories_id']);
                        if(!empty(
$prev_pdf[0]->accessories_fitting_pdf_file))
                        {
                            
$prev_pdf_path DOC_ROOT_FRONT."/images/accessories_images/pdf/".$prev_pdf[0]->accessories_fitting_pdf_file;
                            if(
file_exists($prev_pdf_path))
                            {
                                
unlink($prev_pdf_path);
                            }
                        }
                    }
                    
                    
$this->load->library('upload');
                    
                    
$config = array();
                    
$config['upload_path'] = DOC_ROOT_FRONT."/images/accessories_images/pdf/";
                    
$config['max_size'      '1000000';
                    
$config['allowed_types'] = 'pdf';
                    
//$config['file_name']     = md5(uniqid("100_ID", true));
                
                    
$this->upload->initialize($config);
                    
                    if (!
$this->upload->do_upload("accessories_fitting_pdf_file"))
                    {
                        
$image_error = array('error' => $this->upload->display_errors());
                        echo 
json_encode(array("success"=>false,"msg"=>$image_error['error']));
                        exit;
                    }
                    else
                    {
                        
$image_data = array('upload_data' => $this->upload->data());
                        
$data['accessories_fitting_pdf_file'] = $image_data['upload_data']['file_name'];
                    }
                }
                else
                {
                    
$data['accessories_fitting_pdf_file'] = $_POST['input_accessories_fitting_pdf_file'];
                }
                
                
                
$error "";
                
                
$accessories_id "";
                if(!empty(
$_POST['accessories_id']))
                {
                    
$accessories_id $_POST['accessories_id'];
                    
                    
$data['created_by'] = $_SESSION["webadmin"][0]->user_id;
                    
$data['created_on'] =  date("Y-m-d H:i:s");
                    
$result $this->accessoriesmodel->updateData($_POST['accessories_id'],$data);
                    if(!empty(
$result))
                    {
                        
$error false;
                        
//echo json_encode(array('success'=>'1','msg'=>'Record Updated Successfully'));
                        //exit;
                    
}
                    else
                    {
                        
$error true;
                        
//echo json_encode(array('success'=>'0','msg'=>'Problem in data update.'));
                        //exit;
                    
}
                }
                else
                {
                    
$data['updated_by'] = $_SESSION["webadmin"][0]->user_id;
                    
$data['updated_on'] =  date("Y-m-d H:i:s");
                    
$result $this->accessoriesmodel->insertData('tbl_accessories_master',$data,'1');
                    if(!empty(
$result))
                    {
                        
$accessories_id $result;
                        
$error false;
                        
//echo json_encode(array("success"=>"1",'msg'=>'Record inserted Successfully.'));
                        //exit;
                    
}
                    else
                    {
                        
$error true;
                        
//echo json_encode(array("success"=>"0",'msg'=>'Problem in data insert.'));
                        //exit;
                    
}
                }
                
                if(!
$error)
                {
                    if(!empty(
$accessories_id))
                    {

                        
//accessories image
                        
if(isset($_FILES) && !empty($_POST["input_accessories_image"]) && !empty($_FILES["accessories_image"]))
                        {
                            
$this->load->library('upload');
                            foreach(
$_POST['input_accessories_image'] as $key => $val)
                            {
                                
$accessories_image               = array();
                                
$accessories_image['accessories_id'] = $accessories_id;
                            
                                
$config = array();
                                
$config['upload_path'] = DOC_ROOT_FRONT."/images/accessories_images/";
                                
$config['max_size'      '1000000';
                                
$config['allowed_types'] = 'gif|jpg|png';
                                
//$config['file_name']     = md5(uniqid("100_ID", true));
                            
                                
$_FILES['userfile']['name'    $_FILES['accessories_image']['name'][$key];
                                
$_FILES['userfile']['type'    $_FILES['accessories_image']['type'][$key];
                                
$_FILES['userfile']['tmp_name'] = $_FILES['accessories_image']['tmp_name'][$key];
                                
$_FILES['userfile']['error'   $_FILES['accessories_image']['error'][$key];
                                
$_FILES['userfile']['size'    $_FILES['accessories_image']['size'][$key];
                                
                                
$this->upload->initialize($config);
                            
                                if (!
$this->upload->do_upload("userfile"))
                                {
                                    
$image_error = array('error' => $this->upload->display_errors());
                                    echo 
json_encode(array("success"=>false,"msg"=>$image_error['error']));
                                    exit;
                                }
                                else
                                {
                                    
$image_data = array('upload_data' => $this->upload->data());
                                    
$accessories_image['accessories_image'] = $image_data['upload_data']['file_name'];
                                    
                                    
                                    
$accessories_image_result $this->accessoriesmodel->insertData('tbl_accessories_images',$accessories_image,'1');
                                }
                            }
                        }
                    }
                    echo 
json_encode(array("success"=>true,'msg'=>'Record add/update Successfully.'));
                    exit;
                }
                else
                {
                    echo 
json_encode(array("success"=>false,'msg'=>'Problem while add/update record..'));
                    exit;
                }
                
            }
     }
 
 
 function 
delRecord($id)
 {
 
   $data = array();
    
$data['status'] = "In-Active";
    
$appdResult $this->accessoriesmodel->delrecord("tbl_accessories_master","accessories_id",$id,$data);
     
        if(
$appdResult)
        {
            echo 
"1";
        }
        else
        {
            echo 
"2";    
        }    
 }
 
    function 
deleteAccImage()
    {
        
$accessories_image_id $_POST['accessories_image_id'];
        
$accessories_id $_POST['accessories_id'];
        if(!empty(
$accessories_image_id) && !empty($accessories_id))
        {
            
$condition "accessories_id = '".$accessories_id."' AND accessories_image_id = '".$accessories_image_id."' ";
            
$acc_image $this->accessoriesmodel->getData("tbl_accessories_images",$condition);
            
// echo "<pre>";
            // print_r($prod_drawing_image);
            // exit;
            
if(!empty($acc_image))
            {
                
$acc_image_path DOC_ROOT_FRONT."/images/accessories_images/".$acc_image[0]['accessories_image'];
                if(
file_exists($acc_image_path))
                {
                    if(!
unlink($acc_image_path))
                    {
                        echo 
json_encode(array("success"=>false'msg'=>"Error while deleting image.."));
                        exit;
                    }
                    else
                    {
                        
/* Delete record */
                        
$appdResult $this->accessoriesmodel->delrecords("tbl_accessories_images""accessories_image_id"$accessories_image_id); 
                        if(
$appdResult)
                        {
                            echo 
json_encode(array("success"=>true'msg'=>"Image Deleted Successfully"));
                            exit;
                        }
                        else
                        {
                            echo 
json_encode(array('success'=>false'msg'=>'Problem While Deleting Image..'));
                            exit;
                        }
                    }
                }
                else
                {
                    echo 
json_encode(array("success"=>false'msg'=>"Something Went Wrong!!"));
                    exit;
                }
            }
            else
            {
                echo 
json_encode(array("success"=>false'msg'=>"Something Went Wrong!!"));
                exit;
            }
        }
        else
        {
            echo 
json_encode(array("success"=>false'msg'=>"Something Went Wrong!!"));
            exit;
        }
    }    
    
}

?>
Reply


Messages In This Thread
RE: A PHP Error was encountered Severity: Notice Message: Undefined index: - by trace1301t - 03-07-2019, 03:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB