How can the issue of the SQL syntax error be resolved in the given PHP script?
The SQL syntax error can be resolved by properly escaping the variables before inserting them into the SQL query. This can be done using prepared statements in PHP to prevent SQL injection attacks. By using prepared statements, the variables are automatically sanitized and the SQL syntax error is avoided.
// Assuming $conn is the database connection object
$stmt = $conn->prepare("INSERT INTO table_name (column1, column2) VALUES (?, ?)");
$stmt->bind_param("ss", $value1, $value2);
// Set the values of $value1 and $value2 here
$stmt->execute();
$stmt->close();