DMXzone App Connect Support Product Page

Answered

How do I stop special characters showing as things like ’ ?

Asked 14 Jun 2018 13:25:00
1
has this question
14 Jun 2018 13:25:00 Bruce Wilkie posted:
Hi there

I'm replacing all my old php pages with html pages, using Server Connect and App Connect

But in the new pages I'm seeing jumbled characters like ’ where there used to be normal special characters such as apostrophes etc.

The database is the same and both the php and html pages have the tag <meta charset="utf-8"> in the header.

Is there something else I need to set to fix it so that the html pages show normal special characters?

thanks in advance
Bruce

Replies

Replied 14 Jun 2018 13:40:57
14 Jun 2018 13:40:57 Teodor Kuduschiev replied:
Hi Bruce,

you need to make sure your database collation is set to UTF8 (utf8-general-ci).
Also the PHP scripts you used before may have stored the data in the database incorrectly (not as UTF8) which is now an issue with a real UTF8 database and page.
Replied 14 Jun 2018 13:52:59
14 Jun 2018 13:52:59 Bruce Wilkie replied:
Thanks Teodor

I''ve converted the database to uft8-general-ci now within phpmyadmin.

Characters showing up wrong still, so I'll go through and update the individual characters next, and then update the scripts that insert and edit the data.

Fingers crossed.
Thanks for the quick reply

Bruce
Replied 14 Jun 2018 14:05:34
14 Jun 2018 14:05:34 Teodor Kuduschiev replied:
Converting the database to utf-8 won't fix the issue they have not been added as utf-8 by the PHP script. These have to be manually changed.
Replied 07 Aug 2018 13:41:54
07 Aug 2018 13:41:54 Bruce Wilkie replied:
Hi Teodor

Still having problems with this.

I've set up two pages to display the same data. One using App Connect and one just using PHP to connect and run the query.

The page using PHP to display the database info is working fine but the page using App Connect isn't.

This is the code for the php file that displays the characters correctly:

============

<?php require_once('Connections/mpi_connection.php'); ?>
<?php
mysql_select_db($database_mpi_connection, $mpi_connection);
$query_rs_news = "SELECT *, DATE_FORMAT(news_date,'%e %M %Y') AS fDate FROM news WHERE news_id=155 ORDER BY news_date DESC, news_id DESC";
$query_limit_rs_news = sprintf("%s LIMIT %d, %d", $query_rs_news, $startRow_rs_news, $maxRows_rs_news);
$rs_news = mysql_query($query_rs_news, $mpi_connection) or die(mysql_error());
$row_rs_news = mysql_fetch_assoc($rs_news);
$totalRows_rs_news = mysql_num_rows($rs_news);
?>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Old Site test</title>
</head>
<body>


<p><?php echo $row_rs_news['news_teaser']; ?></p>

</body>
</html>
<?php
mysql_free_result($rs_news);
?>

=====================


This is the htm file using App Connect that doesn't display characters correctly:

=====================

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="dmxAppConnect/dmxAppConnect.js"></script>
</head>

<body id="testnewsitenews" is="dmx-app">
<dmx-serverconnect id="serverconnect1" url="dmxConnect/api/NewsTest.php"></dmx-serverconnect>
<p>{{serverconnect1.data.testquery[0].news_teaser}}</p>
</body>
</html>

======================

Cannot figure out what's causing the problem since they are both accessing the same record in the same table in the same database.

Any ideas?

Hope you can help

Bruce
Replied 08 Aug 2018 06:56:04
08 Aug 2018 06:56:04 Teodor Kuduschiev replied:
Hi Bruce,
The problem with your page is that the data was not stored into the database as UTF8. What i mean is the script you used to store it, didn't properly send it to the database fields as such which is the case if you are using the DW server behaviors to do so. Probably set names utf8 was missing: dev.mysql.com/doc/refman/8.0/en/charset-connection.html

Server connect expects a properly inserted UTF8 data in your database so that it handles it as such, and the result is broken unicode characters.
Replied 08 Aug 2018 15:37:12
08 Aug 2018 15:37:12 Bruce Wilkie replied:
Thanks for the tip there Teodor.

I've googled "set names utf8 dreamweaver server behaviors" and found your response to a similar enquiry on the Wappler support site at community.wappler.io/t/text-with-french-characters-not-displaying-correctly/2091/6

Following the instructions there I've now added the line:

mysql_query('set names utf8', $connection_name);

to the end of the Dreamweaver connection script

All now working great

Thanks again
Replied 08 Aug 2018 17:48:54
08 Aug 2018 17:48:54 Teodor Kuduschiev replied:
Great that you have this fixed
Nice SEO on the wappler community also - this reply is a few hours old

Reply to this topic