gpt4 book ai didi

php - 'SQLSTATE[HY093],我是否把逗号放错了?

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

我的代码大部分已经运行起来了。我似乎不断地一遍又一遍地犯同样的错误。我认为这是因为我在错误的地方放了逗号,但我不知道。谁能帮我看一下这段代码吗?

<?php
$db_server = "localhost";
$db_username = "root";
$db_password = "";
$db_database = "meubelfabriek";
$conn = new PDO("mysql:host=$db_server;dbname=$db_database", $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_POST['submit']))
{
$prijs = $_POST['prijs'];
$naam = $_POST['fname'];
$beschrijving = $_POST['desc'];
$maat1 = $_POST['maat1'];
$maat2 = $_POST['maat2'];
$maat3 = $_POST['maat3'];
$maat4 = $_POST['maat4'];
$imageName = $_FILES["image"]["name"];
$imageData = file_get_contents($_FILES["image"]["tmp_name"]);
$imageType = $_FILES["image"]["type"];
if(substr($imageType,0,5)=="image")
{
$stmt = $conn->prepare("INSERT INTO producten ( naam, beschrijving, prijs, maat1, maat2, maat3, maat4, namen, image ) VALUES ( :naam, :beschrijving, :prijs, :maat1, :maat2, :maat3, maat4,'$imageName', " . $conn->quote($imageData) . ")");
$stmt->execute(array(":naam"=>$naam, ":beschrijving"=>$beschrijving, ":prijs"=>$prijs, ":maat1"=>$maat1, ":maat2"=>$maat2, ":maat3"=>$maat3, ":maat4"=>$maat4));;
}
else
{
echo "Oops, something went wrong!";
}
}
?>

最佳答案

您错过了::

:maat2, :maat3, maat4,'$imageName',  // There is a missing : before maat4

关于php - 'SQLSTATE[HY093],我是否把逗号放错了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47866665/

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