July 19th, 2000, 08:44 PM
I am afraid this is a beginners question, but i hope you give a little help with this.
I want to insert values in a table trough ODBC, here is the code:
$result = odbc_exec($db,"INSERT INTO TABLE (COL1, COL2, COL3, COL4, COL5, COL6) VALUES ($col1, $col2, $col3, $col4, $col5, $col6)");
well, after the sentence $result is not zero, it means that it was well interpreted,
but values were not inserted into table, why?, what should i do?, please help me...
July 19th, 2000, 10:03 PM
I think you might need single quotes around your variables if they're CHARACTER STRINGS but not if they are INTEGERS or FLOATS:
"INSERT INTO table (col1, col2, col3) VALUES ('$col1', '$col2', '$col3')"
I think DATES may also require single quotes.
Some machines require double quotes if ANSI mode isn't enabled.
July 20th, 2000, 09:34 PM
Thanks a lot, but it didnt work, with or without quotes, any oyher ideas?
July 21st, 2000, 12:41 AM
Try it a couple at a time - if there is an error in the format of any of the $col variables its easy to find out which ones this way.
$sql="INSERT INTO TABLE (COL1, COL2) VALUES ('$col1', '$col2')";
$res = odbc_exec($db,$sql);