我使用PHP和试图将项目添加到我的MySQL数据库。PHP不会增加我的SQL项目
如果我使用下面的代码它的工作原理:
mysql_query("INSERT INTO `intranet`.`product_form` (`id`, `ProductName`, `ProductInitiatedBy`) VALUES (NULL, 'item1', 'item2')") or die("Could not perform select query - " . mysql_error());;
不过,如果我使用下面的代码它不工作:
$product_name=("tom");
mysql_query("INSERT INTO `intranet`.`product_form` (`id`, `ProductName`, `ProductInitiatedBy`) VALUES (NULL, $product_name, 'item2')") or die("Could not perform select query - " . mysql_error());;
我得到一个错误,指出:
无法执行选择查询 - '字段列表'中的未知列'ProductName1234'
ProductName1234
是来自$product_name
的数据,应该是我尝试添加的数据而不是列。
首先,格式化你的代码! – 2012-07-16 00:09:40
只是做了..我输入[代码],发现我没有错..现在所有固定。 – Aaron 2012-07-16 00:10:34