0

I have the session created and it stores the data, that is working 100%;

I have a foreach loop that converts all the session data into an array of in_fields and in_values.

But the form is not submitting to the database, please assist !

    // sql fields and values
$in_fields = array();
$in_values = array();


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 .= ")";

if(executeSql($sql)) {
        $id = mysql_insert_id();
                executeSql($sql);
            }
        }

I have created a print_r of $in_fields and $in_values and it displays as an array.

The error i am receiving now:

Warning: trim() expects parameter 1 to be string, array given in E:\xampp\htdocs\sc\form\inc\functions.php on line 22

Database query error. Unknown column 'step' in 'field list'

LIne 22 from Functions.php

    $value = get_magic_quotes_gpc() ? stripslashes($value) : trim($value);  
10
  • 1
    why are you looping the session array, why not just use Serialize - php.net/manual/en/function.serialize.php Commented Mar 17, 2011 at 20:19
  • what about printing query itself? Commented Mar 17, 2011 at 20:20
  • you see no SQL query in your code? Commented Mar 17, 2011 at 20:22
  • printing out sql error will do a little help too. what SQL software it is? Commented Mar 17, 2011 at 20:23
  • @Col. Shrapnel i get the following: INSERT INTO wills(selection, first_name, age, step) VALUES ('1st_Marriage', 'John', '18', '') Commented Mar 17, 2011 at 20:23

1 Answer 1

1

Database query error. Unknown column 'step' in 'field list'

do you need any further explanations?

Sign up to request clarification or add additional context in comments.

1 Comment

@all i got it to work now it was because i had to unset "step" from my session data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.