I have a SQLSERVER 2019 Database with Modern_Spanish_CI_AS collation that allows me to store the letters ñ and special characters, but when the information is displayed in an HTML form it doesn't show the Ñ letter.
In the header i have included UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
I am working under IIS 10 (Windows 10) and PHP 7.4
In the php.ini document the following lines of code were added.
default_charset = UTF-8
internal_encoding = UTF-8
input_encoding = UTF-8
output_encoding = TF-8
mbstring.language = UTF-8
mbstring.internal_encoding = UTF-8
mbstring.http_input = UTF-8
Pictures of HTML Form and Table Information.
HTML FORM
TABLE
Model Code:
public function lista_paises()
{
$respuesta = $this->con->db->execute('lista','paises','');
foreach ($respuesta as $key)
{
echo utf8_decode("<option value='$key[0]'>$key[2]</option>");
}
}
Instance of code that execute SQLSERVER
<?php
class Sqlsrv{
var $host;
var $user;
var $pass;
var $dbName;
function __construct($conf){
$this->host = $conf['host'];
$this->user = $conf['user'];
$this->pass = $conf['pass'];
$this->dbName = $conf['dbName'];
}
public function connect(){
$conn = sqlsrv_connect($this->host,array("UID"=>$this->user,"PWD"=>$this->pass,"Database"=>$this->dbName));
return $conn;
}
public function execute($action,$table,$data){
$cad = '';
foreach ($data as $value) {
$cad = $cad."'".$value."'".",";
}
$cad = substr($cad, 0, -1);
$sql = "exec ps_".$action."_".$table." ".$cad;
$conn = $this->connect();
$result = sqlsrv_query($conn,$sql);
return $this->convertResult($result);
}
private function convertResult($result){
$i = 0;
while($rows = sqlsrv_fetch_array($result)){
$list[$i] = $rows;
$i++;
}
return $list;
}
public function disconnect($conn){
sqlsrv_close($conn);
}
}
?>
I need help to make the Ñ letter display correctly.
Best regards