Php 将字段动态插入表中,但查询出错
} 错误Php 将字段动态插入表中,但查询出错,php,Php,} 错误 测试了打印字段和值,它们是正确的。调用了函数add,然后在语法上出错,但无法判断查询哪里出错 密钥应包装为“而不是” Prepare failed: (1064) 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 ''name','address','country','
测试了打印字段和值,它们是正确的。调用了函数add,然后在语法上出错,但无法判断查询哪里出错 密钥应包装为“而不是”
Prepare failed: (1064) 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 ''name','address','country','type','status') VALUES ('Starbucks','Washington ','U' at line 1
$food->add("food", $_POST, "add");
密钥应该用“而不是”包装
Prepare failed: (1064) 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 ''name','address','country','type','status') VALUES ('Starbucks','Washington ','U' at line 1
$food->add("food", $_POST, "add");
print\r($fields)
和print\r($values)
的Post值以及列和表名中的引号会产生问题!!我认为列字段的数量与相应值的数量不匹配。因为你的错误。('name'、'address'、'country'、'type'、'status')值('Starbucks'、'Washington'、'U')@psyLogic以及列名称中的引号
又如何呢?打印($fields)和打印($value)
的Post值以及列和表名称中的引号都会产生问题!!我认为列字段的数量与相应值的数量不匹配。因为你的错误。('name'、'address'、'country'、'type'、'status')值('Starbucks'、'Washington'、'U')@psyLogic和列名称中的quotes
如何??“做什么?”@joe read哦“做什么?”@joe read
$fields[] = "`$key`";