我正在使用以下代码将数据插入到数据库中..但有时候它可以工作,有时它不起作用。我该怎么做?有人可以帮助我!“
<?php
if(isset($_POST['pub'])){
$category = $_POST['p_category'];
$author = $_POST['p_author'];
$title = $_POST['p_title'];
$content = $_POST['p_content'];
$image_name = $_FILES['p_image']['name'];
$image_type = $_FILES['p_image']['type'];
$image_size = $_FILES['p_image']['size'];
$image_tmp = $_FILES['p_image']['tmp_name'];
$date = date("M,d,Y");
$misc = $_POST['p_misc'];
$video = $_POST['p_video'];
$query = "INSERT INTO `me`(`post_category`, `post_author`, `post_title`, `post_content`, `post_image`, `post_date`, `post_misc`, `post_video`) VALUES ('$category','$author','$title','$content','$image_name','$date','$misc','$video')";
if(mysqli_query($con,$query)){
move_uploaded_file($image_tmp,"images/$image_name");
header("location:view_posts.php?done2=done2.png");
}
else{
echo "<center><h4><font color='red' face='calibri'>Query error!</font></h4></center>";
}
}
?>