This request
$email = $mysqli->real_escape_string($_POST['email']); // User email. $key = RandomString(128); // A random string of 128 characters. $newTime = $_SERVER['REQUEST_TIME'] + 1800; // Expiration timer. $queries[] = "INSERT INTO verification ( email, key, time ) VALUES ( '$email', '$key', $newTime )"; $errors = false; $mysqli->autocommit(false); foreach ($queries as $query) { if (!$mysqli->query($query)) { $errors = true; } }
gives me the following error:
You have an error in the SQL syntax; check the manual that matches the version of your MySQL server for the correct syntax to use next to the key, time. VALUES (' example@domain.net ', 'e1e4091197640bae0a4588b8666e87b6b' on line 1.
But the query above works by simply adding a few backward steps (serious emphasis):
$queries[] = "INSERT INTO verification ( `email`, `key`, `time` ) VALUES ( '$email', '$key', $newTime )";
Can someone explain how this change will fix the problem?
source share