im trying to add data into my database using the data that the user inputs into an html form. Here's my code:
<?php
error_reporting(E_ALL);
$conn = new mysqli(/* private infos hidden on stackoverflow */);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submitButton'])) {
$getName = $_POST['name'];
$query = "INSERT INTO data ('name') VALUES ('$getName')";
if ($conn->query($query) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $query . "<br>" . $conn->error;
}
$conn->close();
}
?>
<html>
<form method="post">
Name: <input type="text" name="name"><br>
<input type="submit" name="submitButton">
</form>
</html>
i get this error:
Error: INSERT INTO data ('name') VALUES ('', '', '', '', '')
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''name') VALU' at line 1
** WHAT I ALREADY TRIED: **
"INSERT INTO data ('name') VALUES ('$getName')";
"INSERT INTO data ('name') VALUES ($getName)";
"INSERT INTO data (name) VALUES ('$getName')";
"INSERT INTO 'data' ('name') VALUES ('$getName')";
"INSERT INTO data (name) VALUES ($getName)";
"INSERT INTO data (name) VALUES '$getName'";
thanks for any help guys