简体   繁体   中英

UTF-8 PHP SQL SERVER

I am working using wordpress, php and sql server. On my web page I have a sqlserver query that is not being displayed correctly.

problem

I am not sure of what should I insert on my php or html code to fix this, I have been trying different things but nothing is fixing my problem. I guess it's all about ut8 encoding but I don't know what to do anymore.

This is how I do the query.

$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
$stmt=$dbh->prepare("SELECT TOP 10 till.code......
$stmt->execute();

尝试这个:

new PDO ("dblib:host=$hostname;dbname=$dbname;charset=utf8","$username","$pw");

Probably it's a problem in HTML generated by Wordpress.

Can you check the meta tags in your HTML?

For HTML4:

<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">

For HTML5:

<meta charset="UTF-8">

You can find further information on charsets here: http://www.w3schools.com/html/html_charset.asp

Furthermore it is available in PHP a function able to convert in HTML encoded strings some special characters; you could try to pass columns with problems through the htmlentities function: http://php.net/manual/en/function.htmlentities.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM