Therefore, I do not know what is wrong here. This is a problem with the quotation mark or not, because when I use a single quote, it seems to work.
Yes, you need to use a single quote.
You can check this out:
$values = implode(', ', array_values($data));
Into something like this:
$values = implode (',', array_map ( function ($z) { return ((is_numeric ($z) || (is_string ($z) ? ($z == "NOW()" ? true : false) : false) || (is_array ($z)?(($z=implode(";",$z))?false:false):false)) ? $z : "'" . utf8_decode ($z) . "'"); }, array_values ($data)));
The idea is that you specify each value field, I meant the value field by the value field in the query. For example, in my example, the function ignores NOW () as a string and saves it as an SQL timestamp. Because if you consider it as a string type, the command will not work correctly.
In any case, the above is ugly and unsafe.
I would advise you to look for an ORM like RedBeanORM or maybe use the right version of PHP MySQL like MySQLi . Mainly to avoid SQL injection.
See one example of ORM:
require 'rb.php'; R::setup(); $post = R::dispense('post'); $post->text = 'Hello World'; $id = R::store($post); //Create or Update $post = R::load('post',$id); //Retrieve R::trash($post); //Delete
See an example PHP version with an improved version of PHP:
$stmt = mysqli_prepare($link, "INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'sssd', $code, $language, $official, $percent); $code = 'DEU'; $language = 'Bavarian'; $official = "F"; $percent = 11.2; mysqli_stmt_execute($stmt);
Good luck. Good training.