I have some UTF-8 characters that were stored incorrectly in my MySQL database, e.g. £
is stored as £
. Since there are too many to manually correct I want to run a query via PHP to get the affected rows and use regular expressions to replace them.
The basic query I am using to test this is:
SELECT *
FROM `notes`
WHERE `notes` LIKE '%£%';
If I run this in phpMyAdmin it returns 754 rows, but in my PHP script it only returns 5 rows:
$query = "SELECT * FROM `notes` WHERE `notes` LIKE '%£%'";
$result = mysqli_query($this->connection, $query);
echo "rows... " . mysqli_num_rows($result));
I also tried setting the character set:
mysqli_set_charset($connection, 'utf-8');
Why does the same query to the same database produce different results?