Adding Session / Array to SQL Database
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);
Database query error. Unknown column 'step' in 'field list'
do you need any further explanations?
精彩评论