我在使用$ _GET作为insert into的值时遇到了一些问题。连接正常,使用普通字符串将导致成功插入数据库:
$sql = 'INSERT INTO product(productplaatje, productnaam, productbeschrijving,
allergieen, productprijs, bijnaop, op)
values("hoi", "hoi","hoi","hoi","1.50",0,0 )';
此代码不:
$sql = 'INSERT INTO product(productplaatje, productnaam, productbeschrijving,
allergieen, productprijs, bijnaop, op)
values(' . $_GET["productimage"] . ', "hoi","hoi","hoi","1.50",0,0 )';
错误代码:
Fatal error: Uncaught PDOException:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'd' in 'field list'
in C:\inetpub\Students\ADSD\2017\s1117723\addsucces.php:66
Stack trace:
#0 C:\inetpub\Students\ADSD\2017\s1117723\addsucces.php(66): PDO->exec('INSERT INTO pro...')
#1 C:\inetpub\Students\ADSD\2017\s1117723\addsucces.php(75): Connection->insertProduct()
#2 {main} thrown in C:\inetpub\Students\ADSD\2017\s1117723\addsucces.php on line 66
有人可以向我解释为什么它不起作用吗?
编辑:为什么这个标记为双重qoutations和单个qouations的一些帖子的副本?我查看了帖子,但我仍然不知道如何解决问题。