Php 使用准备好的语句将图像和日期插入数据库

Php 使用准备好的语句将图像和日期插入数据库,php,mysqli,prepared-statement,Php,Mysqli,Prepared Statement,我尝试将以下查询转换为准备好的语句: $NewPostQ = mysqli_query($con, "INSERT INTO admin_panel(datetime, title, category, author, image, post) VALUES('$DateTime', '$Title', '$Category', '$Admin', '$Image', '$Post')"); 以下是我所拥有的: $NewPostQ = mysqli_prepare($con, "INSERT

我尝试将以下查询转换为准备好的语句:

$NewPostQ = mysqli_query($con, "INSERT INTO admin_panel(datetime, title, category, author, image, post) VALUES('$DateTime', '$Title', '$Category', '$Admin', '$Image', '$Post')");
以下是我所拥有的:

$NewPostQ = mysqli_prepare($con, "INSERT INTO admin_panel(datetime, title, category, author, image, post) VALUES(?, ?, ?, ?, ?, ?)");

$NewPostQ->bind_param("isssbs", $DateTime, $Title, $Category, $Admin, $Image, $Post);
$NewPostQ->execute();

move_uploaded_file($_FILES["Image"]["tmp_name"], $Target);
除了图像和日期时间之外,所有内容都将进入数据库。我有$Datetime,如下所示:

$CurrentTime = time();
$DateTime = strftime("%b-%d-%Y %H: %M: %S", $CurrentTime);
它将变成一个varchar(50),单位为dB。图片如下:

$Image = $_FILES["Image"]["name"];
$Target = "../assets/upload/".basename($_FILES["Image"]["name"]); 

这将进入varchar(200),单位为dB。我的理解是,日期在
bind_param
中表示为整数,图像表示为blob,因此我将它们设置为I和b(
“isssbs”
)。有人知道为什么这样不行吗?在datetime中,我得到一个零,而对于图像,它只是空的

当您在时间上执行strftime()时,它将返回字符串。是的。我将此更改为
s
,现在可以了,谢谢。为什么图像没有绑定为
b
?奇怪的是,它也是
s
。这与我读到的所有内容都背道而驰,但好吧,它起作用了
$Image
是图像的名称,而不是内容。为什么有
“isssbs”
?为什么不仅仅是
$NewPostQ->bind_参数($DateTime、$Title、$Category、$Admin、$Image、$Post)