gpt4 book ai didi

php mysql插入语法错误

转载 作者:行者123 更新时间:2023-11-29 01:29:28 24 4
gpt4 key购买 nike

<分区>

我被这个语法错误难住了(如下):

    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
'desc, barkDesc, flowerDesc, foliageDesc, fruitDesc, type, cat, height, spread, l'
at line 1

让我失望的是像这样传播后的数字 1(高度,传播,1)。

下面是 INSERT INTO 语句的 php 打印,我觉得它很棒。

    INSERT INTO plants 
(botanicalName, commonName, landscapeUses, desc, barkDesc, flowerDesc, foliageDesc, fruitDesc, type, cat, height, spread, lightReq, soil, growth, trimming, fert, otherMaint)
VALUES
('Botanical name', 'Common Name', 'Accent, Edge, Groundcover', 'This is some text description text.', 'bark', 'flower', 'foliage', 'fruit', 'Perennial', '', '18 inches', '18 inches', 'full sun', 'well drained', 'medium', 'trimming', 'fertilization', 'other maintenance')

不用多说,我的 PHP 代码

       $sql2 = "INSERT INTO plants 
(botanicalName, commonName, landscapeUses, desc, barkDesc, flowerDesc,
foliageDesc, fruitDesc, type, cat, height, spread, lightReq, soil, growth,
trimming, fert, otherMaint)
VALUES ('$botanicalName', '$commonName', '$usesString', '$desc', '$barkDesc',
'$flowerDesc', '$foliageDesc', '$fruitDesc', '$type', '$cat', '$height', '$spread', '$lightReq', '$soil', '$growth', '$trimming', '$fert', '$otherMaint')";

$result2 = mysql_query($sql2) or die(mysql_error());
$plantID = mysql_insert_id();
header("location: plantdetail.php?plantID=$plantID");

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com