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

时间:2013-08-29 13:46:55

标签: php insert odbc

我无法将数据插入Access表('test')。我有一个html表单,应该使用我的PHP来INSERT。一切似乎都没问题(没有错误),但是当我看到我的Access表('test')时,没有插入任何东西,我不知道为什么。 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";
?> 

1 个答案:

答案 0 :(得分:1)

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

我的ODBC管理窗口没有标记为“只读”。但是,我的访问数据库不允许常规用户编写或修改。调整文件夹和* mdb文件的权限后,它工作。

感谢Andrewsi帮助我完成这项工作。从现在开始,我将在每个命令之后添加errormsg行!