Connecting to MS Sql Server from php/apache

2012-12-02 Thread Alan Chandler
I have a two virtual machines on my debian unstable desktop machine.  
One runs windows 7 and has an instance of Microsoft SQL Server Express 
running on it.  The other runs Windows XP and has a version of Apache 
and Php together with the Microsoft PHP Drivers.  All three machines 
(the host and the two virtual machines) are networked via a virtual 
bridge, so they all sit in the same subnet and can therefore 
intercommunicate.


In the WindowsXP machine I have set up a test of PHP talking to the SQL 
Server database and this works perfectly. ( I mention this because it 
proves that the database is indeed running and responding to remote 
requests)


I am now trying to replicate that test on my desktop machine using 
FreeTDS.  However I am struggling to make it work.  I have two 
problems.  Firstly I am finding it quite difficult to know precisely 
which Debian packages I need to install to make it all work, and 
secondly with the complicated chain of things I don't really know how 
the error message is telling me what is wrong.


So let me describe the setup in a bit more detail.

1) My local home DNS system identifies the SQL Server machine as 
roo.home.  The instance of SQL Server is called SQLEXPRESS (so from 
windows I would access this server as ROO\SQLEXPRESS


2) On my host machine (called kanga.home) I have 
/etc/freetds/freetds.conf set up (ignoring comment lines) as follows


[global]
text size = 64512

[roodb]
host = roo.home
instance = SQLEXPRESS
tds version = 7.2

3) I have an apache virtual host setup to recognise ac.home as a web 
address with the web root set to a place where I have set up index.php 
as follows


?php
$dsn = 'dblib:server=roodb';
$user = 'accu_app';
$password = '';
try {
$db = new PDO($dsn, $user, $password);
$db-setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
}
catch(PDOException $e) {
die(Failed with message:  . $e-getMessage());
}
echo It worked
?

When I call this configuration from a web browser I get the following 
response


Failed with message: SQLSTATE[HY000] Unable to connect: Adaptive Server 
is unavailable or does not exist (severity 9)



I have no idea whats wrong, and I find it quite difficult to find some 
decent instructions of how to set up a dblib connection.


Can anyone help me investigate and solve this problem

--
Alan Chandler
http://www.chandlerfamily.org.uk


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/50bb0c0d.9050...@chandlerfamily.org.uk



Re: Connecting to MS Sql Server from php/apache

2012-12-02 Thread Alan Chandler

On 02/12/12 08:06, Alan Chandler wrote:


Failed with message: SQLSTATE[HY000] Unable to connect: Adaptive 
Server is unavailable or does not exist (severity 9)




I managed to fix this myself.  There were two problems

1) Password was one character wrong.
2) The connection string should be
dblib:host=roodb;dbname=PAS_Live

That is the host= piece should refer to the name in the 
/etc/freetds/freetds.conf configuration




--
Alan Chandler
http://www.chandlerfamily.org.uk


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/50bb12a2.6040...@chandlerfamily.org.uk