Helo. I am having trouble executing the following INSERT INTO query. The SELECT works fine. Where is the mistake?
The php gives back this error message:
Error: SQLSTATE[42000]: Syntax error or access violation: 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 ''id', 'reg_date', 'szoveg') VALUES (NULL, CURDATE(), 'x')' at line 1
$servername = "localhost";
$username = "root";
$password = "pass";
$dbname = "db";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM Notes");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
if(isset($_POST["szoveg"])){
$query = "INSERT INTO Notes ('id', 'reg_date', 'szoveg') VALUES (NULL, CURDATE(), '".$_POST["szoveg"]."')";
$stmt = $conn->prepare($query);
$stmt->execute();
}