Retrieve Greek Letters From Mssql Database With Php
Solution 1:
A couple of things to maybe try.
1) Can you validate exactly what character encoding your DB is in? I recommend UTF8 for everything as it should handle the widest range of characters. "ASCIIASCII" is not a character encoding to my knowledge do you mean "ASCII"?
2)Try using mysql_set_charset('utf8'); changing the char set to match your db encoding. It "Sets the default character set for the current connection." from within the current php script. PHP official docs
3)This is an outlier but where are you viewing the results? Irrelevant of the data returned from your DB the if you are viewing the results in a web browser you will need to make sure the page has the appropriate charter encoding set in the head if this is a miss match from the character set returned from your db it can result in the question marks or diamonds... Typically something like this
<head><title>page title</title><metacharset="UTF-8" /></head>Solution 2:
I had exactly the same problem with you so when i was searching to find the solution i saw your question.The answer is very simple.I guess somewhere in your code you connect to the database with code like the following :
$serverName = "YOUR_SERVER";
$connectionInfo = array("Database"=>"YourDatabase");
$link = sqlsrv_connect($serverName,$connectionInfo);
if(!$link ) {
die('Could not connect: ' . mysql_error());
}
To make greek characters show up you need to change line 2, from:
$connectionInfo = array("Database"=>"YourDatabase");
to :
$connectionInfo = array("Database"=>"YourDatabase","CharacterSet"=>"UTF-8");
and the rest code stays the same. This solution was suggested by @Graham to his own question i think, and it is from here : Greek character insertion in php compared to SQL server management studio
Post a Comment for "Retrieve Greek Letters From Mssql Database With Php"