Special Characters are not showing correctly

in the tables or selects that have the data source from the database the special characters like “~” are not showing. i even applied the htmlspecialchars(), but its not doing anything.

this an part from the code of an table that i have and this is how i apply the htmlspecialcharacters():

$cell_data = htmlspecialchars($source_t[$i][$h_columns[$j]],true);
                                if (strtoupper($h_columns[$j])=="ESTADO")
                                {
                                    
                                    echo"<td>
                                            <div class=checkbox-wrapper-35>
                                                <input type = hidden name = bk_mode_id[] value = ". ((boolval($cell_data) == true) ? "true" : "false") .">
                                                <input type = hidden name = mode_id[] value = ". ((boolval($cell_data) == true) ? "true" : "false") .">
                                                <input name=check_mode[] id=state_". $source_t[$i]['ID'] ." type=checkbox class=switch  
                                                ".((boolval($cell_data) == true) ? "checked" : "")." onclick = hide_show_bt(this) value =". ((boolval($cell_data) == true) ? "true" : "false") .">
                                                <label for=state_". $source_t[$i]['ID'] .">
                                                    <span class=switch-x-toggletext>
                                                        <span class=switch-x-unchecked><span class=switch-x-hiddenlabel>Unchecked: </span>Fechada</span>
                                                        <span class=switch-x-checked><span class=switch-x-hiddenlabel>Checked: </span>Aberta</span>
                                                    </span>
                                                </label>
                                            </div>
                                        </td>"; 

                                }
                                else
                                {
                       
                                    echo "<td>$cell_data</td>"; 
                                }

please provide url , and try to add charset utf-8 to you db connection file

1 Like

http://intervencoescc.infy.uk/login.php

i can use the account teste. pass = teste

I had a similar problem and i needed to add “charset=utf8mb4” into my connection string when connecting to the database and that fixed it.

My php looked like this

new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8mb4", $username, $password);

Might be worth a try.

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.