I'm trying to extract data from a table in access database using odbc connection and php. I have written the code below but it gives error "Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers
Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'table1.col_date"
<?php $cn = new com("ADODB.Connection");
$rs = new com("ADODB.Recordset");
$cn->open("dsn=odbcconnection");
?>
<form action = "thispage.php" method = "post">
Enter Date : <input type = "text" name = "datadate" />
<input type = "submit" name = "submit" value = "submit" />
</form>
<?php
$datadate = isset($_REQUEST['datadate']) ? $_REQUEST['datadate'] : null; ?>
<?php $sql = "select col_date, sum(qty1), sum(qty2) from table1
where table1.col_date = '".$datadate."'
group by col_date
order by col_date";
// Execute query
$rs = $cn->execute($sql);
I think there is a problem in only parameter line table1.col_date = $datadate because when I replace $datadate with static date like table1.col_date = #05/08/2012# , it displays output correctly for the date
table1.col_date = '$datedate'but still the same but if I change it totable1.col_date = #01/05/2012#, it correctly displays output for 1st May, 2012thispage.phpfile?