PHP/ODBC插入问题-没有错误


PHP/ODBC insert issues - no errors

我在将数据插入Access表("测试")时遇到问题。我有一个html表单,应该使用我的PHP进行INSERT。一切似乎都很顺利(没有错误),但当我查看Access表("测试")时,没有插入任何内容,我不知道为什么。SELECT运行良好,只是由于某种原因我无法插入。

谢谢你的帮助。

test.html:

<html>
<body>
Enter Customer Information
<br>
(* indicates required fields)
<p>
<form action="test.php" method="post">
Last Name*: <input type="text" name="last">
<br>
First Name*: <input type="text" name="first">
</td>
</tr>
<input type="submit">
</form>
</body>
</html>

test.php:

<?php
$conn=odbc_connect('testdb','','');
$sql="INSERT INTO test (last, first)
VALUES
('$_POST[last]','$_POST[first]')" or die (sql_error);
odbc_exec($conn, $sql) or die (exec_error);
odbc_commit($conn) or die (comm_error);
odbc_close($conn);
echo "1 record added";
?> 

问题已解决。在添加odbc_errormsg行后,我得到:[Microsoft][odbc Microsoft Access Driver]操作必须使用可更新的查询。

我的ODBC管理窗口没有标记"只读"。然而,我的访问数据库不允许普通用户写入或修改。在调整了文件夹和*mdb文件的权限后,它就工作了。

感谢Andrewsi帮助我度过难关。从现在起,我将在每个命令后添加errormsg行!