Web page displays '&#26297' as ' 暹'

searching for this has proven to be quite difficult and I imagine there will be other combinations I need to catch.

The MS Sql server database record has this as part of the entered data &#26297
When I pull the record into the web page and display the record via PHP it shows this as

I need to filter the output so that it will show the original input as entered on the web page.

let me add that if I do this in PHP:

echo "&#26297";

Open in new window


I get:

 

I need it to output:

&#26297


when the user puts that into a record.
ZipbangAsked:
Who is Participating?
 
quizwedgeCommented:
Try wrapping the whole string in htmlentities(). See http://php.net/htmlentities for details.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
echo "&#26297"
0
 
Ray PaseurCommented:
We NEVER send unfiltered / unescaped output to a client browser.  If you do that, your site becomes a threat to your user community.  Instead we follow the principles of Filter Input Escape Output.  PHP provides functions to help you do this.  Almost always without exception you must use one of these functions before writing output to the client.  Here are the required reading links:
http://php.net/manual/en/security.general.php
http://php.net/manual/en/function.htmlentities.php
http://php.net/manual/en/function.htmlspecialchars.php

It's old news, but vitally important.
http://shiflett.org/blog/2007/dec/php-advent-calendar-day-13

Here is an example showing how to escape the output.
See: http://iconoun.com/demo/temp_zipbang.php

<?php // demo/temp_zipbang.php

/**
 * http://www.experts-exchange.com/questions/28654457/Web-page-displays-%27-26297%27-as-%27-%27.html
 * http://shiflett.org/blog/2007/dec/php-advent-calendar-day-13
 */
error_reporting(E_ALL);


// USE PHP TO CREATE VARIABLES FOR OUR HTML
$raw  = '&#26297';
$safe = htmlspecialchars($raw);

// CREATE OUR WEB PAGE IN HTML5 FORMAT
$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style type="text/css">
/* STYLE SHEET HERE */
</style>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
/* JQUERY CODE HERE */
});
</script>

<title>HTML5 Page in UTF-8 Encoding</title>
</head>
<body>

<p> Raw: $raw  Safe: $safe</p>

</body>
</html>
HTML5;

// RENDER THE WEB PAGE
echo $htm;

Open in new window

0
 
sarabhaiCommented:
$datavaluevar = "&#26297"
alert( '<?php echo $datavaluevar?>'.replace(/\&amp\;/gi, "&");
0
 
ZipbangAuthor Commented:
thanks for your quick response
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.