gpt4 book ai didi

php - 我不知道的 mySQLi 数据库错误,首先这个查询运行正常但现在不工作

转载 作者:行者123 更新时间:2023-11-30 23:52:47 25 4
gpt4 key购买 nike

我之前运行过此查询并将记录插入数据库,但现在无法正常工作。我搜索了解决方案,我的数据库大小为 1.6MB,并且我将 php.ini 中 xampp 的默认大小从 2Mb 增加到 20MB 并刷新了 apache 和 mysql 服务器。但没有有效的解决方案

这是我的代码

        function saveProduct($myproductName , $myproductType , $mymyimage , $techInfo , $charactristics , $specifications , $properties)
{
$mycon = mysqli_connect("localhost","root","") or die ("could not connected to database");
mysqli_select_db($mycon, "zic_app");
$qry="INSERT INTO zic_catalog (productName, productImage, productType, vhviTech, generalCharactristics, specifications, properties) VALUES ('".$myproductName."' , '".$mymyimage."' , '".$myproductType."' , '".$techInfo."' , '".$charactristics."' , '".$specifications."' , '".$properties."')";
?>
<br /><br /><br />
<?php
$result=mysqli_query($mycon, $qry);
if($result)
{

echo( "publish successfully...");
}
else
{
echo "Product Not published: " . mysqli_error($mycon);
}
}

这是错误

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's manual Transmission fluid specification and other major car manufacturers wher' at line 1

最佳答案

如果数据中有 撇号,它会破坏 sql - 在 sql 中使用转义双引号或使用 htmlentities 转换数据

$qry="INSERT INTO zic_catalog (productName, productImage, productType, vhviTech, generalCharactristics, specifications, properties) 
VALUES
(\"{$myproductName}\" , \"{$mymyimage}\" , \"{$myproductType}\" , \"{$techInfo}\" , \"{$charactristics}\" , \"{$specifications}\" , \"{$properties}\")";

关于php - 我不知道的 mySQLi 数据库错误,首先这个查询运行正常但现在不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40395871/

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