What are some common pitfalls when using MySQL OR statements in PHP?

One common pitfall when using MySQL OR statements in PHP is not properly structuring the query, which can lead to unexpected results or errors. To avoid this, make sure to enclose each set of OR conditions within parentheses to maintain the logical order of operations.

// Incorrect way: 
$query = "SELECT * FROM table WHERE condition1 OR condition2 AND condition3";

// Correct way: 
$query = "SELECT * FROM table WHERE (condition1 OR condition2) AND condition3";