What am i doing wrong
i can insert these vars directly with mysql admin
no problem
when i want to insert the same vars with php code i get an error (mysql 1054)
what do i want to do
i've got a form and i want to insert al my vars from this form in the database
in my var names i use underscores
function save_clientform($array)
{
mysql_connect($server, $db_user, $db_pass) or die ("Error - INSOFF0001");
mysql_select_db($database);
//make a unique id
$aanvraagid = date("Ymd")."_".md5(uniqid(rand(), true));
// build reserved keyword array
$aanvraagidwaarde = addslashes ($aanvraagid);
$reserved_keys[] = "MAX_FILE_SIZE";
$reserved_keys[] = "required";
$reserved_keys[] = "redirect";
// $reserved_keys[] = "email";
$reserved_keys[] = "require";
$reserved_keys[] = "path_to_file";
$reserved_keys[] = "recipient";
$reserved_keys[] = "subject";
$reserved_keys[] = "bgcolor";
$reserved_keys[] = "text_color";
$reserved_keys[] = "link_color";
$reserved_keys[] = "vlink_color";
$reserved_keys[] = "alink_color";
$reserved_keys[] = "title";
$reserved_keys[] = "missing_fields_redirect";
$reserved_keys[] = "env_report";
$reserved_keys[] = "submit";
// $reserved_keys[] = "IDXXX";
// $reserved_keys[] = "IDSITE";
$reserved_keys[] = "incbylage";
if (count($array))
{
while (list($key, $val) = each($array))
{
// exclude reserved keywords
$reserved_violation = 0;
for ($ri=0; $ri<count($reserved_keys); $ri++)
{
if ($key == $reserved_keys[$ri])
{
$reserved_violation = 1;
}
}
// prepare insert
if ($reserved_violation != 1)
{
$keywaarde = addslashes ($key);
$valwaarde = addslashes ($val);
$do="INSERT INTO offerte_data
( aanvraag_id,
variabele_naam,
variabele_inhoud
)
values
(
'$aanvraagidwaarde',
'$keywaarde',
'$valwaarde'
)";
$query = mysql_query($do) or die ("Error - INSOFF0002");
}
}
}
return ;
}
i've tried several options with adding escape codes (with or without addslashes and so on) nothing works
then i tried to insert the values directly in the database with mysqladmin
no problem everything works (including the underscore vars)
when i use the sql generated with the mysqladmin it works in mysql admin but same error (1054) when i put it in my php code
what is my coding that works on mysqladmin sql statement but not in php (except for de $do offcourse ;-) )
$do="INSERT INTO `offerte_data` ( `aanvraag_id` , `variabele_naam` , `variabele_inhoud` )
VALUES ('ab_ddd', 'cd_dd', 'sdjfsdkjfdksf_dsfadf_dasdf-777'
)";
i use the same kind of statement on other places (only then without underscores in the vars) there are no problems there when inserting.
what do i do wrong
some a additional info
PHP Version 4.3.10
MySQL Version 3.23.58
UTF8
magic_quotes_gpc local😮n master😮n
magic_quotes_runtime local😮ff master😮ff
table structure
offerte_data
Field Type Null Default
aanvraag_id varchar(255) No
variabele_naam varchar(255) No
variabele_inhoud longtext Yes NULL
Index :
Key name Type Kardinaliteit Field
variabele_naam INDEX 1 variabele_naam
aanvraag_id INDEX 1 aanvraag_id