I am inserting some data into a fresh table like this:
foreach ($results as $key => $val){
    $sql = "INSERT INTO submission_meta (key, value) VALUES ('".$key."', '".$val."')";  
    if ($conn->query($sql) === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
} 
When i run the above in the foreach with variables i get the follwoing error:
Error: INSERT INTO submission_meta (key, value) VALUES ('first_name', 'John')
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 'key, value) VALUES ('first_name', 'John')' at line 1
If i hard code the data i want to insert, the data goes into the database fine.
Any issues with the above?
 
     
    