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

  • Home
  • SEARCH
  • 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 6666305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:48:53+00:00 2026-05-26T02:48:53+00:00

I want insert following checkbox in a row from database table, but have error,

  • 0

I want insert following checkbox in a row from database table, but have error, how is fix it? (I can not change 5 in name checkbox)

<input type="checkbox" name="checkbox_units_a[5][]" value="tv">
<input type="checkbox" name="checkbox_units_a[5][]" value="radio">

$name_un = $this -> input -> post('name_units_a');
$service_un = $this -> input -> post('checkbox_units_a');
$data3 = array();
foreach($name_un as $idx => $name) {
    $data3[] = array(
    'name_un' => $name_un[$idx],
    'service_un' => json_encode($service_un[$idx]), ); //This is line 210
};
$this -> db -> insert_batch('hotel_units', $data3);

Error:

A PHP Error was encountered
Severity: Notice
Message:
Undefined offset: 0
Filename: residence.php
Line Number:
210

My output in var_dump from $name_un:

array(1) {
    [0] = > string(6)"accessories"
}

My output in var_dump from $service_un:

array(1) {
    [5] = > array(2) {
        [0] = > string(15)"tv" [1] = > string(12)"radio"
    }
}
  • 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-05-26T02:48:53+00:00Added an answer on May 26, 2026 at 2:48 am

    Error says your offset is equal 0 propably your $idx == 0 and $service_un[$idx] == null 😉

    EDIT

    As I thought $idx == 0 is causing undefined offset 0 in json_encode try to reindex your $service_un array (if you cannot change the 5 in HTML) to make it start with 0 example:

    $service_un = array_values ( $service_un ); // reindexing array
    

    it will look like:

    array(1) {
      [0] => array(2) {
        [0] => string(2) "tv"
        [1] => string(5) "radio"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script that I want to insert into a table, but
I want to insert a new row into a msaccess table using the following
I want to insert a new row into an Access database. I'm looking at
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
I have the following xml and want to insert additional xml into it: <root>
i want to insert values into a table, with an INSERT INTO statement but
I want to insert the following into a database: (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #text9#), (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#,
If I want to insert into a database column of type char(2) from C#.
I want to insert top 20 ROWS from a table tbl_A in db_A to
I have a user table. I want to insert data into my user table.

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.