I have a table with 3 columns : id
, food_name
, and category
.
For example, I have $food_name = "Amaranth grain, cooked"
(there is a comma), and category = "Cereals"
.
I can t insert the values and have the following error:
Could not connect: 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 )
VALUES ( Amaranth grain, cooked , ) at line 1
我要问:
$results1 = mysql_query("
INSERT INTO " . $table . " (food_en, category)
VALUES ( " . $food_name . " , " . $category . " )"
)or die(mysql_error());
我的猜测是,“阿马兰特谷、 co”中的ma正在造成一个问题,但我可以解决这个问题。 I Trial str_replace( , , , , , $food_name)
and mysql_real_einski_string(
. 我也许没有使用这些物品。
提前感谢。
www.un.org/spanish/ecosoc EDIT:我的确重复了“类别”,它并不完全无效或空洞(价值为Cereals/strong)。
当我印刷时,我没有使用我的频率,我得到:
INSERT INTO calories (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO carbohydrates (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO fats_and_fatty_acids (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO protein_and_amino_acids (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO vitamins (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO minerals (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO sterols (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )
INSERT INTO other (food_en, category)
VALUES ( Amaranth grain, cooked , Cereal Grains and Pasta )Could not connect: 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 )
VALUES ( Amaranth grain, cooked , ) at line 1
(不同表格只是不同的表格,我希望插入一线)