复选框和foreach

时间:2013-04-04 06:22:41

标签: php mysql

我要打开一个复选框来存储它我检查 但是我收到了一个错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Array, 5' at line 1

我现在更新了我的代码,我得到了一个新的错误:

“无法添加或更新子行:外键约束失败(dashboarddas_custermers_employees,CONSTRAINT das_custermers_employees_ibfk_5 FOREIGN KEY(das_employess_id)参考{{1} }(das_employer_roles))“

希望有人可以提供帮助......我已经把我所有的代码都放在了希望有人能看到错误的地方

我的HTML

id

这是表架构: Here is the database schema:

2 个答案:

答案 0 :(得分:0)

你遗失了什么......请在下面查看......

mysql_query("INSERT INTO das_custermers_employees(das_employess_id, employees_role_id, das_custermers_id) VALUES ($employess_hidden, $em_id, $user_custermers_id)") or die(mysql_error());

答案 1 :(得分:0)

我想:

mysql_query("INSERT INTO das_custermers_employees(das_employess_id, employees_role_id, das_custermers_id) VALUES ($employess_hidden, $employess_roles, $user_custermers_id ") or die(mysql_error());

应该是:

mysql_query("INSERT INTO das_custermers_employees(das_employess_id, employees_role_id, das_custermers_id) VALUES ($employess_hidden, $em_id, $user_custermers_id ") or die(mysql_error());

您试图将数组插入到INSERT语句中,而不是foreach循环中的元素。

另外,改变:

$employess_hidden = $_POST["employess_id_$em_id"];

为:

$employess_hidden = $_POST["employess_hidden_$em_id"];

表单中没有employess_id_XXX输入。