Quoting Ovidiu Gabor <[EMAIL PROTECTED]>:
> 
> FS> Din cate vad din intrebare vrei o conexiune la mssql ( microsoft) ?
> FS> daca este asa , atunci tre sa pui ODBC pe statia Windows, si dupa
> FS> aceea totul este ok.
>
>   Cu freetds inca imi mai bat capul acum.
>   Daca nu cer prea multe... ODBC drivers pt. Win de pe unde se poate
>   aduna? :) Nu vin implicit cu MS-SQL Server? (e un sqlserver2000 ).
>   Ar fi mai practica varianta cu ODBC ce e drept.

Am vazut ca au trecut citeva zile si tot nu s-a rezolvat discutia asta,
asa ca am cautat niste instructiuni pe care le aveam din vremuri
imemoriale pentru PHP+MSSQL pe Linux, folosind freetds+unixodbc. Nu
mai stiu unde le-am gasit (parca in niste comentarii pe phpbuilder) dar
ideea e ca functioneaza fara probleme (testat personal).

----------------------------------------------------------------------
How to make php capable of connecting to SQL Server 2000:

1. UNIXODBC

Get unixodbc. Compile with:
# ./configure --prefix=/opt/unixodbc --sysconfdir=/etc \
--localstatedir=/var

Install.

2. FreeTDS

Get FreeTDS. Compile with:
# ./configure --prefix=/opt/freetds --sysconfdir=/etc \
--localstatedir=/var --with-unixodbc=/opt/unixodbc \
--enable-msdblib --with-tdsver=8.0

Install.

3. PHP

Install PHP with these options:
--with-mssql=/opt/freetds

4. Set environment vars:

export SYBASE=/opt/freetds
export TDSVER=8.0
export FREETDSCONF=/etc/freetds.conf

5. Configure FreeTDS:

Edit /etc/freetds.conf, add this:

[MsSqlServer]
host = MS.SQL.SERVER.IP
tds version = 8.0
port = 1433
try server login = yes

6. Configure unixODBC driver:

Edit /etc/tds/tds.driver.template, add this:

[TDS]
Description     = Free TDS
Driver          = /opt/freetds/lib/libtdsodbc.so
FileUsage       = 2

Then execute this command to activate the configuration:
# odbcinst -i -d -f /etc/tds/tds.driver.template

7. Configure unixODBC data source:

Edit /etc/tds/tds.datasource.template, add this:

[Fast]
Driver        = TDS
Description   = Some MSSQL database
Trace         = No
Servername    = MsSqlServer
Database      = DBNAME
UID           = USERNAME

Execute this command to activate the configuration:
# odbcinst -i -s -f /etc/tds/tds.datasource.template

8. Test FreeTDS

Try to connect using this command (you will be prompted for password):
# tsql -S MS.SQL.SERVER.IP -U USERNAME

9. Test PHP

Check phpinfo(), it should have the "mssql" entry.

This code should work:

$ident=mssql_connect('MsSqlServer','USERNAME');
mssql_select_db('DBNAME');
$result=mssql_query('select top 20 * from TableNameHere');
echo '<TABLE border=1>';
while ($row=mssql_fetch_row($result)) {  
  echo '<tr>';
  for ($i=0;$i<count($row);$i++) echo '<td>'.$row[$i];
}
echo '</TABLE>';
----------------------------------------------------------------------


-- 
GZ

--- 
Detalii despre listele noastre de mail: http://www.lug.ro/


Raspunde prin e-mail lui