I'm trying to insert the data that's in the form into the database that I made. I keep getting this error when I check if the data is in the database:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_comments' at line 1
This is my php:
<?php
$db_connection = mysqli_connect('localhost','root','',"project_online_planner");
if (!$db_connection){
die('Failed to connect to MySql:'.mysql_error());
}else{
echo "it worked";
}
if(isset($_POST['insertComments'])){
$name=$_POST['name'];
$comment=$_POST['comment'];
mysqli_query($db_connection,"INSERT INTO user_comments (name, comment) VALUES ($name, $comment)");
Print "Your information has been successfully added to the database.";
}
?>
This is my html:
<div id="uploadComments">
<form id="insertComments" name="insertComments" method="post">
<label for="name">Name: </label><input type="text" id="name" name="name"><br/>
<label for="comment">Comments: </label><textarea name="comment" id="comment"></textarea>
<input type="submit" value="Submit">
</form>
</div>