What is the significance of using single quotes around variables in a MySQL query in PHP?

When writing a MySQL query in PHP, it is important to use single quotes around variables in the query to ensure that the query is executed correctly. This is because variables should be treated as strings in the query, and using single quotes helps to differentiate them from other parts of the query. Failure to use single quotes can result in syntax errors or unexpected behavior in the query execution.

// Example of using single quotes around variables in a MySQL query in PHP
$variable = "example";
$query = "SELECT * FROM table WHERE column = '$variable'";
$result = mysqli_query($connection, $query);