I am running a PHP/MySQL insert query using the following code below. I am getting no error, and the query goes off with success. However the database is not updated. I have tested the SQL inside phpAdmin and it does work. I am using binding to add my variables to the SQL query. The only thing I can think of is that the bindings are not working. Is there any way to get the error logs. I cannot seem to find them on XAMPP or online, unless I am terrible at searching for them. Or perhaps someone can see the error in my code below.
<?php
$conn = mysqli_connect("localhost","root","M0nkwork", "blogs");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
else{
$msg = '';
$msgClass = '';
if(filter_has_var(INPUT_POST, 'submit')){
//Send PHP to database
$SQL = "INSERT INTO Blogs(UserID, Title, Author, Blog, Date) VALUES (?,?,?,?,?)";
$stmt = $conn->prepare($SQL);
$stmt->bind_param("issss", $UserID, $Title, $Author, $Blog, $Date);
$Author = $_POST['Author'];
$Title = $_POST['Title'];
$BlogEntry = $_POST['BlogEntry'];
$Date = $date = date('m/d/Y h:i:s a', time());
$UserID = 1;
if(!empty($Author) && !empty($Title) && !empty($BlogEntry)){
$stmt->execute();
$stmt->close();
$msg = 'Success';
$msgClass = 'alert-success';
}else{
$msg = 'Please Fill in all fields';
$msgClass = 'alert-danger';
}
}
}
?>