I have to sync with two tables in the database
The following is the error I get:
A database error has occurred
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO client (interior_client_name, Interior_client_email, interior_client_mobile, interior_house_id) VALUES ('a', 'b', '8989898', Array)
Filename: C:\xampp\htdocs\ThinkInterio\system\database\DB_driver.php
Line Number: 330

These are the two tables as shown below :

The view file template is as follows:

<form id="formID" class="formular" method="post" action="<?php echo base_url(); ?>admin/startdetails" enctype="multipart/form-data">  
                    <!-- Start Content Start -->
                    <div class="visualizeContent" style="display:block;" id="start">
                            <li class="heading">Client Details</li>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Name</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="interior_client_name" class="validate[required]"/></div>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Email ID</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="Interior_client_email" class="validate[required]"/></div>
                            <li class="clearfix">
                                <div class="leftLabelName">Client Contact Number</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="interior_client_mobile" class="validate[required]" /></div>
                            <li class="heading">
                                Basic Details
                            <li class="clearfix">
                                <div class="leftLabelName">House Type</div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent">
<select name="interior_house" id="interior_house_desc" class="validate[required]">
                                    <option value="">Please select</option>
                                    <?php foreach($house as $ho){ ?>
                                    <option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>
                                    <?php } ?>
                            <li class="clearfix">
                                <div class="leftLabelName"><strong>Carpet Area</strong></div>
                                <div class="middleDivider"></div>
                                <div class="RightContent"><input type="text" name="Interiror_client_carpet_area" class="validate[required]"/></div>

                           <?php foreach($roomtype as $co){
                            <li class="clearfix">

                                <div class="leftLabelName"><?php echo $co['interior_room_desc']?></div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="text" name="roomType[<?php echo $co['interior_room_id']?>]" /></div>
                            </li> <?php } ?>

                            <li class="clearfix">
                                <div class="leftLabelName">Upload Floor Plan <small style="color:#A4A3A3;">(Max 1MB)</small></div>
                                <div class="middleDivider">:</div>
                                <div class="RightContent"><input type="file" /></div>
                            <li class="clearfix nextPrev displayNone">
                                <div class="leftLabelName">&nbsp;</div>
                                <div class="middleDivider">&nbsp;</div>
                                <div class="RightContent">
                                    <input type="submit" class="previous" value="Previous" />
                                    <input type="submit" class="next" value="Next" />
                    </div><!-- Start Content End -->

My functions are as follows in the controller, can anyone help me with what has gone wrong? I have to post values in those two tables, and I have tried something on the lines of those. below

public function starting()
  //start in interior table
    $this->load->view('template/admin', $data);   
public function startdetails()


$roomTypes =explode(',', $this->input->post('roomType'));   
foreach($roomTypes as $key=>$roomType){
                'interior_client_trans_no_room_id' => $key,
                'interior_house_no_rooms' => $roomType
                echo '<pre>';


$this->db->set('se_erm_client_id', $data);

$this->db->set('interior_house_no_rooms', $startid);
$this->db->insert('client_trans',$rdata); */
foreach($_POST['user'] as &$user)
   // $user['additional_data'] = $_SESSION['additional_data'];
  //  $user['current_time'] = time();
    $this->db->insert('client_trans', $user);


I have attached the file view, as in how it looks. Please help me, as to how to?

Recommended Answers

Line 32:

<option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>

Change $ho('interior_house_id') to $ho['interior_house_id'] and it should work. Also I suggest you to use $this->input->post() instead of $_POST since it sanitized by the framework (if $config['global_xss_filtering'] = TRUE;). Bye!

Jump to Post

All 4 Replies

For some reason the variable in line 17 contains an array. Debug that value to see if it's set and read correctly.

Hi Pritaeas, Look in line 21 of the view file that I have posted. Isn't it like a select function dropdown? Like I enter in the master table of 'house'(as in the type of houses, independent, villa, etc etc) I have gotten the values from the database table 'house' to the dropdown. I'm not sure, though. I'm confused tbh. Please explain a bit more, if I'm wrong or I couldn't understand. Thanks for the response.

I understand that at first glance it looks like it should work. That's why I suggested to debug the values involved to see if something has gone wrong.

Line 32:

<option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>

Change $ho('interior_house_id') to $ho['interior_house_id'] and it should work. Also I suggest you to use $this->input->post() instead of $_POST since it sanitized by the framework (if $config['global_xss_filtering'] = TRUE;). Bye!

Be a part of the DaniWeb community

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