Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:23:01+00:00 2026-06-18T04:23:01+00:00

Trying to insert an array with the help of CodeIgniter Active reacords. Table has

  • 0

Trying to insert an array with the help of CodeIgniter Active reacords. Table has just two columns id(autoincrement pk column) and value.

$data array I am populating from Google Contact API response. Here how I am populating array $data in controller and passing it to model

$val = $client->getIo()->authenticatedRequest($req);//Getting response from Google Contact API.
$xml = simplexml_load_string($val->getResponseBody());
$result = $xml->xpath('//gd:email');  //Fetching email addressed from the response
foreach ($result as $title) {
            array_push($gmailContacts, mysql_real_escape_string($title->attributes()->address));
 }
$this->load->model('gmailContacts');
$this->gmailContacts->saveContacts($gmailContacts);

Model Code is

  function saveGmailContacts($data=array()) 
  {
    $this->db->insert('contact_table',$data);
  }

Error is

Error Number: 1054

Unknown column '0' in 'field list'

INSERT INTO `importedgmailcontacts` (`0`, `1`, `2`, `3`, `4`, `5`)VALUES ('VALUE1', 'VALUE2', 'VALUE3','VALUE4', 'VALUE5') 

I am using Codeigniter with XAMPP 1.7.7 which has PHP 5.3.3 and MySql 5.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:23:02+00:00Added an answer on June 18, 2026 at 4:23 am

    CodeIgniter assumes when you pass an array like that that you are setting a single row with multiple columns. The array keys are the column names and the values are what goes into the row. You will need to call insert multiple times, once for each row, if you want to use the ActiveRecord class.

    You will likely be better off rolling your own query for this one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert an array of new contacts from a temporary import table
I am trying to insert the value to the mysql table using php. But
I'm trying to insert into an array at a certain point: $hi = test;
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I am trying to insert data to a new empty table. But I keep
I'm trying to figure out how to de-reference a value in an array but
I am trying to clone a table row and generate an array with id
I am trying to take data from one mysql table and insert it in
I am trying to get multiple rows to insert into a mysql table from
Im trying to insert RoomType array into the excel book. Range of RoomType is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.