I've been using odbc functions for quite a while and I was floored when I finally read the details about the how the parameters are handled when they start and end with single quotes! I assumed that the main reason for odbc_execute vs. odbc_exec was to prevent sql injection but apparently this added feature actually opens another security hole, perhaps worse. This was my fix:
<?php
function odbc_execute_clean_parameters($result_id, $parameters_array){
for($i = 0; $i < count($parameters_array); ++$i){
if( substr($parameters_array[$i], -1) == "'" && substr($parameters_array[$i], 0 ,1) == "'" ){
$parameters_array[$i].= " ";
}
}
return odbc_execute($result_id, $parameters_array);
}
$stmt = odbc_prepare($conn, " insert into mytable (col1, col2) values (?, ?) ");
$r = odbc_execute_clean_parameters($stmt, array( $val1, $val2 ) );
?>