What are common pitfalls when using the mysql_query function in PHP for database queries?

One common pitfall when using the mysql_query function in PHP for database queries is the lack of error handling. If there is an error in the query, it will not be caught and can lead to unexpected behavior. To solve this, you should always check the result of the query and handle any errors appropriately.

$result = mysql_query($query);
if(!$result) {
    die('Error in query: ' . mysql_error());
}