What potential issues can arise when using the "like" operator in a PHP MySQL query, especially when searching for partial strings?

When using the "like" operator in a PHP MySQL query to search for partial strings, potential issues can arise if the input contains special characters like "%" or "_", which are wildcards in SQL. To avoid this issue, you can escape these special characters using the mysqli_real_escape_string function in PHP before constructing the query.

$search_term = mysqli_real_escape_string($conn, $_POST['search_term']);
$query = "SELECT * FROM table_name WHERE column_name LIKE '%$search_term%'";
$result = mysqli_query($conn, $query);