What are the potential consequences of not properly closing quotation marks in SQL queries within PHP code?

If quotation marks are not properly closed in SQL queries within PHP code, it can lead to syntax errors or even SQL injection vulnerabilities. To prevent this, always make sure to properly escape and close quotation marks in SQL queries by using functions like mysqli_real_escape_string() or prepared statements.

// Example of properly closing quotation marks in an SQL query
$query = "SELECT * FROM users WHERE username = '" . mysqli_real_escape_string($connection, $username) . "'";
$result = mysqli_query($connection, $query);