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
Replied 31 Jul 2023 11:01:24
31 Jul 2023 11:01:24 User  replied:
If you're wondering how to prevent special characters from appearing, look no further than magicalkits.com. When dealing with text input, websites, or applications, it's essential to implement proper validation and sanitization techniques to avoid displaying unwanted characters. By following best practices and utilizing tools like regular expressions, input filters, and encoding methods, magicalkits.com ensures a seamless user experience while keeping special characters at bay.
Replied 05 Aug 2023 10:09:00
05 Aug 2023 10:09:00 User  replied:
If you're encountering issues with the display of special characters, particularly in scenarios involving web addresses like https://www.ufabetwins.info/ufabetทางเข้า/ it's essential to address this problem to ensure optimal user experience. Special characters can sometimes disrupt the intended formatting or functionality of a website or application. To prevent these characters from appearing incorrectly, it's recommended to validate and sanitize input data, encode URLs properly, and utilize appropriate character encoding standards. By implementing these practices, you can effectively mitigate the display of unwanted special characters and ensure the seamless presentation of content, including complex URLs like the provided example.
Replied 01 Nov 2023 13:22:13
01 Nov 2023 13:22:13 Bobby Stone replied:
I found the most beautiful and fascinating one. Wolfenstein Jacket
Replied 02 Nov 2023 10:25:07
02 Nov 2023 10:25:07 Andrew Jackson replied:
Excellent blog! Such clever work and exposure! Keep up the very good work. Silver Puffer Jacket
Replied 23 Dec 2023 05:17:32
23 Dec 2023 05:17:32 Lorena Duran replied:
It was not first article by this author as I always found him as a talented author. Death Row Records Varsity Jacket
Replied 26 Dec 2023 05:33:21
26 Dec 2023 05:33:21 User  replied:
This blog was very nicely formatted; it maintained a flow from the first word to the last. sean diaz life is strange 2 hoodie

Reply to this topic