sql server - Umlauts with PHP and MSSQL -
i facing problem umlauts , php / mssql.
on php have following code:
ini_set('mssql.charset','latin1_general_ci_as'); $dbhandle = mssql_connect('xxxxx', 'xxxxx', 'xxxxx') or die("couldn't connect sql server"); mssql_select_db('xxx', $dbhandle); $stmt = mssql_init('esy_getpricevp', $dbhandle); //item code umlaut $itemid = 'he51grün'; mssql_bind($stmt, '@itemid', $itemid, sqlvarchar); $result = mssql_execute($stmt); if (!mssql_num_rows($result)) { echo 'keine datensaetze gefunden<br>'; } else { ($i = 0; $i < mssql_num_rows($result); ++$i) { echo 'preis fuer artikel ',mssql_result($result, $i, 'amount'); } }
i executing stored procedure esy_getpricevp
finds price of item itemid
. if have itemid
without umlaut doing fine.
in procedure converting itemid
nvarchar: convert (nvarchar(50), @itemid)
the complete stored procedure:
alter procedure [dbo].[esy_getpricevp] -- add parameters stored procedure here @itemid nvarchar(20) = 0 begin -- set nocount on added prevent result sets -- interfering select statements. set nocount on; -- insert statements procedure here declare @pricegroup varchar(10); declare @subsegment varchar(20); declare @pricepricegroup numeric(28,12); declare @pricepricesegment numeric(28,12); declare @pricelinedisc numeric(28,12); set @pricegroup = 'vp'; --set @itemid = 'he51grün'; --= convert (nvarchar(50), @itemid) select @pricepricegroup = min(pricedisctable.amount) pricedisctable pricedisctable.dataareaid = 'vv' , pricedisctable.itemrelation = convert (nvarchar(50), @itemid) , pricedisctable.accountrelation = @pricegroup , ( getdate() >= pricedisctable.fromdate or pricedisctable.fromdate = '01-01-1900' ) , ( pricedisctable.todate < '01-01-1901' or getdate() <= pricedisctable.todate ) , (pricedisctable.quantityamount = 1 or pricedisctable.quantityamount = 0) select case when @pricepricegroup null 0 else @pricepricegroup end amount end
if uncomment '--set @itemid = 'he51grün';' statements returns correct price.
spend time in finding solution - can me.
have ever tried set charset connection @ runtime? utf-8 should work.
ini_set('mssql.charset', 'utf-8');
you can set setting directly in php.ini, if want so.
maybe have play utf8_decode
, utf8_encode
in addition.
hast du mal probiert, das charset für die verbindung zu setzen? utf-8 sollte da funktionieren.
ini_set('mssql.charset', 'utf-8');
das kannst du auch direkt in der php.ini setzen, dann gilt das für alle verbindungen auf dem server.
vielleicht brauchst du zusätzlich utf8_decode
und utf8_encode
, damit das passt (für jeden string dann).
Comments
Post a Comment