I'm going to get right to the problem. A line in my code seems to be acting up. It returns with the else and doesn't seem to want to run it. There is no errors in it but it just won't move it to the database. As the title says, it is a mysqli_query in an if statement. Here is the code, I have put arrows to where the errors seems to be.
$t_name = $_POST['topic_name'];
$content = $_POST['con'];
$date = date("y-m-d");
if(isset($_POST['submit'])) {
if($t_name && $content) {
if(strlen($t_name) >= 10 && strlen($t_name) <= 70) {
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
if($query = mysqli_query($connect, "INSERT INTO topics('topic_id', 'topic_name', 'topic_content', 'topic_creator', 'date') VALUES ('', '".$t_name."', '".$content."', '".$_SESSION["username"]."', '".$date."')")) {
echo "<font color = 'green'>Topic posted!</font>";
} else {
echo "<font color='red'>Unknown failure, time to panic!</font>";
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
} else {
echo "<font color='red'>Topic name must be between 10 and 70 characters long!</font>";
}
} else {
echo "<font color='red'>All fields must be filled out!</font>";
}
}
} else {
include('header.php');
echo "You must be logged in to access this page. Click <a href='login.php'>here</a> to login.";
}
include('footer.php');
Yes, I am aware of the dangers of SQL injection and other things, I will deal with it once I have my codes down.