class Index_model extends MY_Model {
protected $user_id=array();
private $last_id;
public function __construct(){
  $this->load->database();
$this->_table='profiles';
    }
  public function insert_step_1($spram) {
     $firt_name= $this->session->userdata('first_name');
    if($first_name == '' || $last_name == '' || $relationship_to_senior == '' || $email == '' || $insurance == '' ||
            $price_range == '' || $if_insurance == '' || $facility_placement == '' || $location == ''  || $telephone == '')
            {}
            else 
            { $insert_data = array ('first_name' => $first_name, 'last_name' => $last_name, 'relationship_to_senior' => $relationship_to_senior, 'email' => $email, 'insurance' => $insurance, 'price_range' => $price_range, 'if_insurance' => $if_insurance, 'facility_placement' => $facility_placement, 'location' => $location,'telephone'=>$telephone);
        $this->db->insert ( 'default_leads_forms', $insert_data );

        $this->last_id = $this->db->insert_id();
        $this->session->set_userdata('tmp_last_id',$this->last_id);
        }   
    }
    public function addLeads_duplicate($spram){

        $var = $this->session->userdata('tmp_last_id',$this->last_id);
        print_r($var);
        //$this->db->insert('default_leads_duplicate',$spram);
        foreach ($spram as $row) {
            $user_id=array(
    'user_id'=>$row['user_id'], );
     $this->db->where('id',$id);
        $res=$this->db->get('default_leads_forms');
        $result=$res->result_array();enter code here

    }

Hello,

can you explain the issue? Currently I see few errors in the first method, as you are not declaring the variables checked by the IF statement.

Also the second method, i.e. addLeads_duplicate(), seems to be truncated. This in particular:

$result=$res->result_array();enter code here

Will generate an error because enter code here must be commented or removed.

In addition to Cereal's observations, if extending a class, and if the child class has its own contructor, the parent's constructor must explicitly called like so...

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Index_model extends MY_Model {

        public function __construct(){

            ## before loading anything like library and helper
            parent::__construct();

        }


        }

I hope that helps a little.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.