Database entry - not sure what's happening...
| From: | dems at sdimaps dot com | Date: | Mon, 20 Nov 2000 23:44:32 +0000 |
| Subject: | Database entry - not sure what's happening... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-4588@lists.php.net to get a copy of this message | ||
Hello,
I am using an SQL wrapper function to enter customer information into an
Interbase 6.0 database (with php version 4.0.3pl1). To process the
HTTP_POST_VARS variables from the entry form, I am using the following
snippet to set the variable $varList as "key1"=>"value1",
"key2"=>"value2", ... "keyn"=>"valuen". This is the
format the SQL
wrapper accepts.
If I echo "$varList", it is in the proper format, i.e.
"Company"=>"Some Company", "State"=>"IN"
and if I hardcode the above $varList in place of "$varList", the values
are inserted properly. The problem occurs with the statement:
$values = array ($varList);
it is returning an SQL error - token unknown. I don't know enough about
php to completely understand what is happening. Is there some processing
being done to the variable $varList because of the format? Any ideas?
Thanks for helping!
<code snippet>
$i = 0;
$varList = "";
while ((list ($key, $val) = each ($HTTP_POST_VARS)) and ($key != "submit")){
if ($i > 0 and $val != ""){
$varList .= ", ";
}
if ($val != ""){
$varList .= "\"$key\"=>\"$val\"";
}
$i++;
}
$values = array ($varList);
$error = InsertQuery ("Contacts", $values);
if (!empty($error)){
echo "Error: $error<br>\n";
}
</snippet>
Daniel Ems
----------------------------------------------------------------------
"Now you know that evil will always triumph, because good... is dumb."
-Dark Helmet (Rick Moranis)
----------------------------------------------------------------------