What is the correct syntax for comparing a string in a MySQL query in PHP?

When comparing a string in a MySQL query in PHP, it is important to properly enclose the string value in single quotes. This ensures that MySQL interprets the value as a string and not a column name or keyword. Failure to do so may result in syntax errors or unexpected results in the query. Example:

// Assuming $conn is the MySQL database connection object
$stringValue = "example";
$sql = "SELECT * FROM table_name WHERE column_name = '$stringValue'";
$result = $conn->query($sql);

// Rest of the code to process the query result