'SQLSTATE [HY093],我把逗号的位置写错了吗?

我得到我的代码主要是跑步。我似乎不断地一遍又一遍地得到同样的错误。我想这是因为我把一个逗号放在了一个错误的地方,但我不知道。任何人都可以帮助我使用这段代码?'SQLSTATE [HY093],我把逗号的位置写错了吗?

<?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 

回答:

您有一个额外的分号在这一行:

$stmt->execute(array(":naam"=>$naam, ":beschrijving"=>$beschrijving, ":prijs"=> 

$prijs, ":maat1"=>$maat1, ":maat2"=>$maat2, ":maat3"=>$maat3, ":maat4"=>$maat4));; <--

回答:

问题是如果声明

$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));;

您可以添加双引号。删除一个。

以上是 'SQLSTATE [HY093],我把逗号的位置写错了吗? 的全部内容, 来源链接: utcz.com/qa/262584.html

回到顶部