[英]Warning: SQLite3::query() [sqlite3.query]: 1 values for 2 columns
I am using an sqlite3 db in php wich i want to fill, i need to fill in a foreign key and the name of the subcategory, here's the code that i use. 我在PHP中使用sqlite3 db,我要填写,我需要填写外键和子类别的名称,这是我使用的代码。
var_dump('"'.$categoryRow.','.$subcategory.'"');
$db->query('INSERT INTO Subcategories (fk_cat, subcat) VALUES ("'.$categoryRow.','.$subcategory.'")');
$subCategoryRow = $db->lastInsertRowID();
die();
But when i run this code, it returns: 但是,当我运行此代码时,它返回:
string(11) ""1,subcategory""
Warning: SQLite3::query() [sqlite3.query]: 1 values for 2 columns in /mysite/product.php on line 94
but when i log them i get 1 and ''subcategory' back. 但是当我登录它们时,我得到1和“子类别”。
Does anyone know what i am doing wrong? 有人知道我在做什么错吗?
your variables should be both surrounded by double quotes sql should be insert into (field1, field2) values ("value1","value2") 您的变量都应该用双引号括起来sql应该插入到(field1,field2)值(“ value1”,“ value2”)中
var_dump('"'.$categoryRow.','.$subcategory.'"');
$db->query('INSERT INTO Subcategories (fk_cat, subcat) VALUES ("'.$categoryRow.'","'.$subcategory.'")');
$subCategoryRow = $db->lastInsertRowID();
die();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.