我正在尝试使用PHP和MYSQL上传三张图片和一些与汽车相关的文字。 最初,我收到消息“MYSQL已经消失......”所以我将max_packet大小增加到500M。 。数据库名称,表名都正确。
以下是我使用过的php代码。
<?php
if(isset($_POST["submit"]))
{
$check1 = getimagesize($_FILES["image1"]["tmp_name"]);
$check2 = getimagesize($_FILES["image2"]["tmp_name"]);
$check3 = getimagesize($_FILES["image3"]["tmp_name"]);
if($check1 !== false and $check2 !== false and $check3 !== false)
{
$img1 = $_FILES['image1']['tmp_name'];
$imgContent1 = addslashes(file_get_contents($img1));
$frontimg = $imgContent1;
$img2 = $_FILES['image2']['tmp_name'];
$imgContent2 = addslashes(file_get_contents($img2));
$backimg = $imgContent2;
$img3 = $_FILES['image3']['tmp_name'];
$imgContent3 = addslashes(file_get_contents($img3));
$intimg = $imgContent3;
$kms = htmlentities($_POST["kms"]);
$make = htmlentities($_POST["make"]);
$model = htmlentities($_POST["model"]);
$variant = htmlentities($_POST["variant"]);
$reg = htmlentities($_POST["year"]);
$color = htmlentities($_POST["color"]);
$owner = htmlentities($_POST["owner"]);
$price = htmlentities($_POST["price"]);
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'car';
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
// Check connection
if($db->connect_error)
{
die("Connection failed: " . $db->connect_error);
}
$insert = $db->query(" insert into car( frontimg, backimg, intimg, kms, make, model, variant, reg, color, owner, price )
values ('$frontimg', '$backimg', '$intimg','$kms','$make', '$model', '$variant', '$reg', '$color',
'$owner','$price') ");
if($insert)
{
echo "data stored successfully";
}
else
{
echo "Check your query";
}
}
}
?>
php返回“检查您的查询”文本,指示SQL代码中的错误。 这里可能出了什么问题..