Page 1 of 1

xampp and sqlserver

PostPosted: 30. October 2006 13:59
by jupela
Hello,
I have a windows 2003 server with the last version of xampp, I have to connect to sqlserver through php but I have some errors. My code is the next:
--------------------------------------------------------------------------------------------------
<?php
$connectID = mssql_connect("server","user","pw");
mssql_select_db("Horaris",$connectID);
$result=mssql_query("select * from cpd_esp_espacios_i",$numero );
while ($row=mssql_fetch_array($result)) {
$counter++; $c1=$row["Alias"];
$c2=$row["Nombre"];
echo ("$counter c1: $c1 c2: $c2\n");
}
mssql_close($conectID);
?>
-------------------------------------------------------------------------------------------------
and the error is:
--------------------------------------------------------------------------------------------------
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:
'server' in C:\Archivos de programa\xampp\htdocs\sqlserver_test\ejemplo_horaris.php on line 2
--------------------------------------------------------------------------------------------------
Someone can help me?[/i]

PostPosted: 31. October 2006 17:31
by jupela
Now, I know what is the problem but not the solution:
The SQLServer has a 'DNS name' and 'DNS Alias' if you put in the sentence mssql_connect
the 'DNS name' the php works correctly but if you put 'DNS Alias' the php cannot find the server.
I have tested the DNS server and if with other commands like 'ping' or 'nslookup' can reach the SQL Server and all is ok.
Also, I work with xampp under Linux and there aren't problems.

Someone knows what can I do?

thanks,

PostPosted: 01. November 2006 05:02
by Izzy
Has this FAQ item anything to do with your issue?

I do not get any connection to my MS SQL server!
http://www.apachefriends.org/en/faq-xam ... l#phpmssql

PostPosted: 02. November 2006 10:21
by jupela
Yes, I put a newer "ntwdblib.dll" in the \xampp\apache\bin directory such as the FAQ article explains in http://www.apachefriends.org/en/faq-xam ... l#phpmssql
Then if you put he 'DNS name' the php works correctly but if you put 'DNS Alias' the php cannot find the server.
The script was the next:
this works:
<?
$sql = mssql_connect ("DNS_Server_name", "user", "pass") or die ("Could not connect to database:" . mssql_get_last_message());
?>

but this doesn't:
<?
$sql = mssql_connect ("DNS_Server_alias", "user", "pass") or die ("Could not connect to database:" . mssql_get_last_message());
?>


If I don't resolve this problem I cannot work with xampp.

Tanks,

PostPosted: 10. November 2006 12:36
by jupela
For if someone needs it I have obtained a solution, with the version ntwdblib.dll-2000.80.194.0 it's works ok.