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 4072554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:53:59+00:00 2026-05-20T16:53:59+00:00

Hello Stack Overflow i hope you are well today; I have a form that

  • 0

Hello Stack Overflow i hope you are well today;

I have a form that uses $_SESSION to store the data at the end of the form i require that it submits to a database.

Within my form there is an option to allow the user to add a new input based on their children.

For example if they user has a child they press a button and jQuery adds an input field, this input then outputs the data into the session as

$_SESSION[‘children’];

Here is the array data (with some samples thrown in);

Array ( [0] => Natural Chlid 1 [1] => Natural Chlid 2 [2] => Natural Chlid 3 ) 

My issue is that i am now submitting the data to the database, i can send all other instances of the form for example ‘first_name’ ‘last_name’ without any issue to the database in one SQL query:

$sql  = "INSERT INTO wills(";
$sql .= implode(", ",$in_fields);
$sql .= ") VALUES (";
$sql .= implode(", ",$in_values);
$sql .= ")";

Firstly the SQL insert query above does not add the chlidren to the database as it picks up the value “array”.

I plan to store the data into the children field as a serialized format for querying purposes.

I am having issues trying to insert the array into the children field but i have managed to get it working without any variables as a dummy test.

$sql  = "INSERT INTO wills(children) VALUES (bob john simon)";

Also the issue with the above is that it adds it to a new database row and not the same row.

Here is the full code:

// sql fields and values
$in_fields = array();
$in_values = array();
$in_children = serialize($_SESSION['children']);

foreach($_SESSION as $key => $value) {
    if(!empty($value)) {
        $value = sql_escape($value);
        $key = explode("#",$key);
            $in_fields[] = "`{$key[0]}`";
            $in_values[] = "'{$value}'";
    }
}


if(!empty($in_fields)) {




    $sql  = "INSERT INTO wills(";
    $sql .= implode(", ",$in_fields);
    $sql .= ") VALUES (";
    $sql .= implode(", ",$in_values);
    $sql .= ")";



    executeSql($sql);

}

print_r’s of my variables

$in_field

Array ( [0] => `selection` [1] => `first_name` [2] => `middle_name` [3] => `last_name` [4] => `spouse_name` [5] => `street` [6] => `city` [7] => `state` [8] => `zipcode` [9] => `email` [10] => `phone` [11] => `cell` [12] => `children_spouse` [13] => `deceased_children_option` [14] => `children_deceased` [15] => `children_under_18` [16] => `1st_guardian` [17] => `2nd_guardian` [18] => `age` [19] => `disabled_children` [20] => `children_disabled` [21] => `children` [22] => `trustee_1` [23] => `trustee_2` [24] => `trustee_children` [25] => `executor_1st` [26] => `executor_2nd` [27] => `spouse_executor_1st` [28] => `split_trust` [29] => `child_share` [30] => `grandchild_share` [31] => `child_share_split` [32] => `distribute_outside` [33] => `share_outside` [34] => `spouse_how_share` [35] => `child_spouse_share` [36] => `spouse_distribute_outside` [37] => `poa_name_1` [38] => `poa_relationship_1` [39] => `poa_telephone_1` [40] => `poa_name_2` [41] => `poa_relationship_2` [42] => `poa_telephone_2` [43] => `spouse_poa_name_1` [44] => `spouse_poa_relationship_1` [45] => `spouse_poa_telephone_1` [46] => `spouse_poa_name_2` [47] => `spouse_poa_relationship_2` [48] => `spouse_poa_telephone_2` [49] => `hc_poa_name_1` [50] => `hc_poa_relationship_1` [51] => `hc_poa_telephone_1` [52] => `hc_poa_name_2` [53] => `hc_poa_relationship_2` [54] => `hc_poa_telephone_2` [55] => `spouse_hc_poa_name_1` [56] => `spouse_hc_poa_relationship_1` [57] => `spouse_hc_poa_telephone_1` [58] => `spouse_hc_poa_name_2` [59] => `spouse_hc_poa_relationship_2` [60] => `spouse_hc_poa_telephone_2` [61] => `physician` [62] => `spouse_physician` [63] => `deeds` [64] => `deed` ) 

$in_values

Array ( [0] => '2nd_Marriage' [1] => 'First nAME' [2] => 'Middle Name' [3] => 'Last Name' [4] => 'Spouse Full Name' [5] => 'Street Address' [6] => 'City' [7] => '2' [8] => 'Zipcode' [9] => 'email Address' [10] => 'phone number' [11] => 'cell number' [12] => '' [13] => 'yes' [14] => '' [15] => 'yes' [16] => 'Guardian 1' [17] => 'Guardian 2' [18] => '20' [19] => 'yes' [20] => '' [21] => '' [22] => 'Sucessor Trustee 1' [23] => 'Sucessor Trustee 2' [24] => 'Children Sucessor Trustee' [25] => 'First Executor' [26] => 'Second Executor' [27] => 'Spouse\'s Executor' [28] => 'yes' [29] => 'yes' [30] => 'yes' [31] => 'yes' [32] => 'yes' [33] => 'Estate Distrubution' [34] => 'Spouse\'s Estate Distribution' [35] => 'no' [36] => 'no' [37] => 'POA 1' [38] => 'Relationship poa 1' [39] => 'telephone poa 1' [40] => 'POA 2' [41] => 'Relationship poa 2' [42] => 'telephone poa 2' [43] => 'spouse poa 1' [44] => 'spouse Relationship poa 1' [45] => 'spouse telephone poa 1' [46] => 'spouse poa 2' [47] => 'spouse Relationship poa 2' [48] => 'spouse telephone poa 2' [49] => 'poa health 1' [50] => 'poa health relationship 1' [51] => 'poa health telphone 1' [52] => 'poa health 2' [53] => 'poa health relationship 2' [54] => 'poa health telphone 2' [55] => 'spouse poa health 1' [56] => 'spouse poa health relationship 1' [57] => 'spouse poa health telphone 1' [58] => 'spouse poa health 2' [59] => 'spouse poa health relationship 2' [60] => 'spouse poa health telphone 2' [61] => 'yes' [62] => 'yes' [63] => 'yes' [64] => '5' ) 

$in_children

Array ( [0] => Natural Chlid 1 [1] => Natural Chlid 2 [2] => Natural Chlid 3 ) 
  • 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-20T16:54:00+00:00Added an answer on May 20, 2026 at 4:54 pm

    Not sure exactly what your issue is, but note that the string values being inserted must be enclosed in quotes:

    INSERT INTO myTable (field1, field2) VALUES ('value1', 'value2')
    

    It doesn’t matter if you use single or double quotes, though in your case you’d be better using single quotes since you use double quotes for your php strings.

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

Sidebar

Related Questions

Hello I am working with a simulator that uses rcS scripts to boot, this
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello we have an SQL server application running over a low bandwith connection. We
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello I was writing a Regular Expression (first time in my life I might
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of
Hello , I am currently working on the student association's website. The student's association
Hello there and Merry Christmas !!! I am new to WPF and I am

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.