PHP a výběr dat z MS SQL 2005
Potřebuji dostat data z jedné tabulky, který je v MS SQL databázi.
Normálně se na ní připojím, vše funguje. Ale jakmile se snažím vybrat sloupec, který obsahuje údaje ve formátu XML, tak mi to hlásí nějakou podivnou chybu s kodováním.
Na webu jsem nalezl něco ve smyslu, že si mám ten sloupeček převést na text, jenže to mi hlásí, že XML se na text převést nedá :(.
Měl by někdo prosím nějaký nápad?
Kód:
Warning: mssql_query() [function.mssql-query]: message: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.
Re: PHP a výběr dat z MS SQL 2005
Kód:
if you get a "Unicode data in Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier" error you can use this kind of code (in an MS environment, of course):
<?
$db = new COM("ADODB.Connection");
$dsn = "DRIVER={SQL Server}; SERVER={SERVER};UID={USER};PWD={PASS}; DATABASE={DB}";
$db->Open($dsn);
$rs = $db->Execute("SELECT * FROM table");
while (!$rs->EOF)
{
echo $rs->Fields['column']->Value."<BR>";
$rs->MoveNext();
}
?>
nebo zkus vymenit ntwdblib.dll vice zde
Re: PHP a výběr dat z MS SQL 2005
Ty jo, díky moc. Kde si to prosím tě našel, já googlil půl dne a nikde nic.
Jinak to provozuji na IIS serveru.
To DLL vypadá zajímavě, ale kde to seženu a kam to mám nahrát?
Přiznám se, že s MS SQL nemám žádné zkušenosti.
Re: PHP a výběr dat z MS SQL 2005
chvilku jsem googlil a nasel jsem to tady
protoze jsem se MS SQL dost venoval, tak jsem si rikal ze by se mi to taky mohlo nekdy prihodit
dll prepis v:
WINDOWS\SYSTEM32
program files\apache2\bin
php
stahnes napr tady ale nezkousel jsem
snad to pomuze
Re: PHP a výběr dat z MS SQL 2005
Tak mi nefunguje nic :).
Ten kód se mi vůbec nějak neprovede, zobrzí se mi jako text od místa Open($dsn);.
Soubor ntwdblib.dll jsem si stáhnul nový a v PHP přespsal, ale taky to ničemu nepomohlo :(
Re: PHP a výběr dat z MS SQL 2005
Tak se mi podařili spojení a výběr rozjet pomocí extenze sqlsrv, což funguje. Ale problém je, že musí být nainstalován MS komponenta, která asi těžko pojede na Linuxu, na kterém server pojede :(.