I have inherited an almost completed php application that I need to get working. It uses an MS Access database via a system DSN.
I have successfully added data from some parts of the application. There is one particular part where I am having trouble. I print the odbc error message and the exectuted sql statement when it fails. I can copy the sql statements and paste them into an access query and they run fine. I have tried the dates without any punctuation, and also replacing the # sign with single quote, only the statement with the # signs runs in access, none of them run from php.
Here is the code that executes the query:
$result = odbc_exec($odbc, $queryToExecute);
if (!$result){
// query failed
print "<BR>-----<BR> QUERY FAILED <BR>" .
"-----<BR>" . $queryToExecute .
"<BR>Error Message: " . odbc_errormsg($odbc) .
"<BR><BR> + + + + + + + + + + + + + + +<BR>";
}
Here are the err messages and SQL statements:
QUERY FAILED *
-----
delete from FoodOrder where FoodOrder.StudentID='1w23' and FoodOrder.Date <= #09/30/2004# and FoodOrder.Date >= #09/01/2004#
Error Message: [Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
+ + + + + + + + + + + + + +
QUERY FAILED *
-----
insert into FoodOrder values ('1w23', 'cs01', #09/01/2004#, 1)
Error Message:
+ + + + + + + + + + + + + +
QUERY FAILED *
-----
update Account set AccountBalance = '7.5' where UserID = 'swright'
Error Message:
+ + + + + + + + + + + + + +
$result = odbc_exec($odbc, $queryToExecute);