Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > PHP and SQL Server
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 12th March 11:45
david.bercot
External User
 
Posts: 1
Default PHP and SQL Server



Hi,

I'd like to connect to SQL Server (it is MSDE from SQL Server 2000) from
PHP.
My system is Debian.
I've installed FreeTDS and some dependencies...

Here is my /etc/freetds/freetds.conf :
[global]
# TDS protocol version
tds version = 4.2
[etemptation]
host = 10.21.2.203
port = 1433
tds version = 8.0

Then, my /etc/odbc.ini :
[etemptation]
Description = TDS MSSQL Server
Driver = /usr/lib/odbc/libtdsodbc.so
Server = 10.21.2.203
Database = etemptation
Port = 1433
TDS_Version = 8.0

And, my /etc/odbcinst.ini :
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout = 5
CPReuse = 5
UsageCount = 1

My PHP test page is :
<?php
$cnx = odbc_connect("etemptation", "idep", "password");
if(!$cnx) {
echo 'problem connexion';
}
else {
echo 'connexion OK';
$sql ="SELECT * from HOPPOIN";
$rs = odbc_exec($cnx,$sql);

while(odbc_fetch_row($rs)) {

}

odbc_free_result($rs);
odbc_close($cnx);
echo 'connexion fermee';
}
?>

But the result is :
Warning: odbc_connect() [function.odbc-connect]: SQL error:
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL
state S1000 in SQLConnect in /home/david.bercot/Internet/test_mssql.php
on line 2 problem connexion

I've also tried in a shell :
p3010-ac-nantes:/home/david.bercot/Internet# isql -v etemptation
src/tds/login.c: tds_connect: 10.21.2.203:1433: Connexion refusée
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08S01][unixODBC][FreeTDS][SQL Server]Server is unavailable or does not
exist. [ISQL]ERROR: Could not SQLConnect

Do you have any idea for my problem ?

Thank you very much.

David.
  Reply With Quote


  sponsored links


2 12th March 11:45
mikeosmith
External User
 
Posts: 1
Default PHP and SQL Server



I vaguely remember having to add :1433 to the freetds.conf on one
Debian server. A quick google turns up this, but I think I put the
serverort on one line (i.e. 192.168.1.11:1433):

http://lists.evolt.org/archive/Week-of-Mon-20030915/148291.html


--
Mike
  Reply With Quote
3 12th March 15:16
david.bercot
External User
 
Posts: 1
Default PHP and SQL Server


Hi Mike,

And thank you for your help...

Le Mon, 21 May 2007 13:21:35 -0400,
"Mike Smith" <mikeosmith@gmail.com> a écrit :


I've tried some modifications and I've searched for others ideas with
Google, but nothing's right !!!
I don't know at all what to do...

May be a miracle if someone can help me ?

Thank you very much.

David.
  Reply With Quote
4 12th March 15:16
tijnema
External User
 
Posts: 1
Default PHP and SQL Server


Is the SQL server and the PHP script running on the same machine? If
so, you should specify 127.0.0.1 or localhost for the server, and not
the IP.

Tijnema
  Reply With Quote
5 12th March 15:17
david.bercot
External User
 
Posts: 1
Default PHP and SQL Server


Le Tue, 22 May 2007 14:18:31 +0200,
Tijnema <tijnema@gmail.com> a écrit :


No. SQL Server is under Windows XP and the PHP script is under
Debian !!!

David.
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666