I have a mysql table with a text field containing German text with German quotes. E.g. „Freda“
.
If I read the database directly via php the result is correct. But when I generate a shortcode in wordpress that contains the same php query of the database, the german quotes disappear. All other characters are displayed.
The db-field and the DB is set to 'utf8mb4_unicode_ci', the html site is set to 'charset="UTF-8"' . When i read out the data with php and show them on a website all german special chars like Ä,ä,Ü,ü,ß are shown correct. But the german quotation marks disapear. For example when this is in the DBfield: " Uhr „jeweils zur vollen Stunde“ in der" the Browser shows: " Uhr jeweils zur vollen Stunde in der". When i copy the text from the browser and paste it in this textarea you see: " Uhr jeweils zur vollen Stunde in der" I tried also to set "mysqli_set_charset('utf8mb4', $link);" before i set the "query mysqli_query( $db, $sql )" but this does not help. If i set "SET NAMES 'utf8mb4'" i got this "Uhr âjeweils zur vollen Stundeâ in "
For this reason i want to change the german quotation marks in the DBfield to '„'
'“'
.
With the following command I can replace the quotes with the entity '„'
or '“'
using phpmyadmin:
UPDATE `TableName` SET `fieldname` = REPLACE(`fieldname`, '„', '„') WHERE `fieldname` LIKE '%„%' COLLATE utf8mb4_bin
But when I want to do this directly using php, I can't manage it. I can change other characters or words but nothing happens with the quotes. How must the command be formulated in the php file so that I can change it?
I was trying the following codes // as given me from phpmyadmin:
$sql = "UPDATE `TableName` SET `fieldname` = REPLACE(`fieldname`, \'„\', \'„\') WHERE `fieldname` LIKE \'%„%\' COLLATE utf8mb4_bin";
$sqlRes = mysqli_query( $db, $sql );
I changed it to:
$sql = "UPDATE `TableName` SET `fieldname` = REPLACE(`fieldname`, '„', '„') WHERE `fieldname` LIKE '%„%' COLLATE utf8mb4_bin";
$sqlRes = mysqli_query( $db, $sql );
I changed it to:
$sql = "UPDATE TableName SET fieldname = REPLACE(fieldname, '„', '„') WHERE fieldname LIKE '%„%' COLLATE utf8mb4_bin";
$sqlRes = mysqli_query( $db, $sql );
I changed it to:
$sql = "UPDATE TableName SET fieldname = REPLACE(fieldname, \'„\', \'„\') WHERE fieldname LIKE \'%„%\' COLLATE utf8mb4_bin";
$sqlRes = mysqli_query( $db, $sql );
But nothing is working.