right I'm running a mssql stored procedure in PHP and the accented characters appear to be returned as ? The stored procedure is
ALTER PROCEDURE [dbo].[dbname]
@ProjectID AS int
AS
SELECT ProjectName 开发者_高级运维COLLATE SQL_Latin1_General_CP1_CI_AS AS ProjectName,
CustomerName COLLATE SQL_Latin1_General_CP1_CI_AS AS CustomerName
FROM Project
WHERE ProjectID = @ProjectID
END
My PHP relating to this is (the return values shown are for ABCDĒčďāĀÖØÖÖÃēù)
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
$stmt=mssql_init("select.Project", $dbhandle);
$desktopid = $_GET['desktopid'];
$compid = 0;
$custid = 0;
mssql_bind($stmt, "@ProjectID", $desktopid, SQLINT4, FALSE, FALSE);
$result = mssql_execute($stmt);
$row = mssql_fetch_assoc($result);
echo $row['ProjectName']; ==== ABCD????????????
utf8_decode($row['ProjectName']); ==== ABCD????????????
utf8_encode($row['ProjectName']); ==== ABCD????????????
I could do with a hand figuring out how to decode the characters that the function returns I've found no help from other sources online and I've even tried several fixes from stack overflow to no avail.
Please also note that if I had the choice I would be using mysql with php not mssql and that I have php running on a debian server
I needed to call ini_set('mssql.charset', 'UTF-8');
(or change that setting in the php.ini file).
Thank you to Mikael Eriksson for giving me the search term I was missing (unicode) to help me find the answer on http://agimpert.blogspot.com/2011/01/unicode-php-headaches.html
精彩评论