开发者

PHP UPDATE MSDB datetime memo Please Help me not go crazy

In PHP I am connecting to an access database using ODBC. I update several fields no problem, but I am having a hell of a time getting two of them to work开发者_JS百科.

First one is of type date/time in access.

Second one is of type memo in access.

$mdbFilename = "pathTo.mdb";
$cimdb = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);

$sqlInsert = "UPDATE MyTable ";
$sqlInsert .= "SET ";
$sqlInsert .= "Time='07:30:00 AM', ";
$sqlInsert .= "Note='My really long note here...' ";
$sqlInsert .= " WHERE ID=777";
$res = odbc_exec($cimdb, $sqlInsert);

The code produces.....

UPDATE MyTable SET Time='07:30:00 AM', Note='My really long note here...' WHERE ID=555  

I have tried soo many things from casting to converting, to different types of spacing/formatting. I really hope someone has done this before.

What I really need to know is What format do I put the data in to get the access DB to accept the input?

Here is the error it throws...

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement., SQL state 37000 in SQLExecDirect in H:\web\count\countInject.php on line 116
SQL statement failed with error: 37000: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

Thank you MUCH for reading this through, and double thanks if you help me out =)


When debugging, I find it helpful to break problems into the smallest chunks possible. For example, is it possible to separate the datetime update from the memo update to ensure you're troubleshooting the right problem.

For Access datetime values, it expects a format of #yyyy-mm-dd HH:MM:SS# from Formatting Date Time Values for Access SQL Ignore the delphi bit, just translate it to PHP.

For Memo, it doesn't look like there's any real special tricks. However, you might be running into an unescaped parenthesis in your source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜