display special chars in php

Simon Leung
Simon Leung used Ask the Experts™
I find that the hyphen saved in mysql field can't be displayed properly from php. Is it related to database definition or on the php ocde ?


<div class="container">
  <div class="row">
    <div class="col-md-12">
        <img  style='float:left;width:200px; margin-right:30px;' src="{$row['image_path']}" alt="Lights"

                  <b>Synopsis</b> <br/>{$row['description']}<br/>
                  Duration: {$row['runningTime']} <br/>
                  Release at: {$row['releaseDate']}<br/>
                  Movie type: {$row['genre']}
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Is it possible it is a "different" hyphen from a tekst editor using UTF-8..?
it doesn't look like it is a ascii 'dash'  / minus character.
ste5anSenior Developer

It's not a hyphen as Noci pointed out.

Your maybe using UTF of some kind, but it can be another code-page based charset also.

1) As your producing HTML, you need to format your data before pushing it into the HTML. E.g. the dates etc. It's not a good idea to use default/implicit formatting.

2) Your data types are not correct. Running time should be an INT, ReleaseDate a DATE, both not [N]VARCHAR. If the genre is not used for a tag cloud only, then it should exist a genre table and a junction table between your movies and the genres.

On your HTML page into the <head>

<meta charset="UTF-8">

Open in new window

and make sure you save the page using UTF-8 encoding (it have to select the option in Notepad++ or it is default using Bracket editor)

In DB function I think you already save ok
you can use

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial