Menu

MS SQL Server configuration

Help
Nick Veit
2010-03-31
2013-05-30
  • Nick Veit

    Nick Veit - 2010-03-31

    I've spent hours trying to get phpgedview to work with MS SQL Server and I'm about ready to chuck in the  towel…I can find bits of documentation but nothing that lets me set it up properly.

    HELP - who has done this and can provide some advice?

    I have MSSQL 2005 on Windows 2003 server IIS 6.

    I've installed PHP and fastch and the sql driver for php. I've created a database in SQL. I've even created a system DSN to it.

    Installation Wizard displays but above it I get:

    ERROR 2: PDO::__construct():  A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:0)
    0 Error occurred on in function __construct
    1 called from line 115 of file class_pgv_db.php in function createInstance
    2 called from line 276 of file session.php in function require_once
    3 called from line 75 of file config.php in function require_once
    4 called from line 42 of file install.php
    Warning: PDO::__construct():  A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:0) in C:\Inetpub\family\PhpGedView\includes\classes\class_pgv_db.php on line 115

    Ignoring that, I enter:
    database type: odbc
    host: 127.0.0.1 (also tried (local) and localhost)
    port: 1433
    username: sa
    password: *******
    database: phpgedview
    Use the database to provide UTF-8 collation: No
    Database Table Prefix: pgv_

    When I click next I get:

    Your current database configuration is bad. Please check your database connection parameters and configure again.
    SQLSTATE SQLConnect: 0  Data source name not found and no default driver specified.

    What should I be doing ?????

     
  • Stephen Arnold

    Stephen Arnold - 2010-04-01

    Not sure you can support PDO with MS-SQL 2005, but I am sure someone will pipe up and confirm. Current support for MySQL, PostgreSQL. and SQLite only.

     
  • Nick Veit

    Nick Veit - 2010-04-01

    The readme.txt and other documentation says SQL Servr is (perhaps newly) supported:

    Database
        You will need at least 1 database and a username and password to access it.
        PhpGedView primarily supports MySQL, but has also been tested and shown to
        work with Postgresql, SQLite, and SQL-Server. The versions required for
        each of these databases is outlined below:
        MySQL 4.1+
        PostgresQL 8.0+
        SQLite available through PDO-SQLite which is included in PHP 5
        MS SQL-Server 2003+

     
  • Greg Roach

    Greg Roach - 2010-04-01

    nick-v

    None of the developers have access to sql-server, and to our knowledge nobody is currently using it.  However, I've just had another look at the documentation for PDO/mssql here http://uk2.php.net/manual/en/ref.pdo-dblib.php

    It looks like the connection string is wrong.  In the file includes/classes/class_pgv_db.php, at line ~167 you will find this:

    "mssql:host={$DBHOST};dbname={$DBNAME}".($DBPORT ? ",{$DBPORT}" : ''), $DBUSER, $DBPASS,

    Check the notes at my first link, and experiment with the syntax in this line.  The bit near the DBPORT looks suspicious.  Try removing it.

     
  • roland_l

    roland_l - 2010-04-01

    Hello Nick-v:

    While I don't know why your IIS / M$sql install is not permitting PGV to connect to it, I can tell you that you are not alone. I have seen in many SourceForge forums (with other pHp projects like PGV) the same issue. So mainly what I want to share is a word of encouragement and a few bits of my experience using the (similar, but less powerful) M$sqlExpress product. Hang in there, Nick (I tend to over-type) !

    Much of my experience is also reflected in the link that Fisharebest gave you above, in that Windows is a strange animal when it comes to hosting a DB. Your best clues will probably come from a log file which in the path of your SQL install. In there you will find the IP address, the InstanceName, and port# that your DB is actually running on. It looks like our PGV connection script allows for specified and/or undeclared Ports (around that line 167 statement). In my experience in a Windows server environment, the SQL Port must be declared in order to connect (unless you use something called Named Pipes) . But we must first know what it is, not assuming it will be the default one used for MSSQL. There can also be Firewall issues when trying to connect to a SQLserver over a LAN if the particular port is one known to be used for viruses (ie. the SQL-Slammer virus of a few years ago used 1433, among others.) But, my friend Google told me that somewhere in your SQL Admin panel you can AllowAll IP addresses and/or Ports if you are sure this is what you want to do. Another thing she said was about making sure you have the right .DLL file (in the right place) for M$sql and pHp to play well together. Again, even some of the old posts in the link given above gives you a good feel for what I am describing - making sure the DB is accessible first before trying to connect.

    Just in case, I also found the following HowTo for a well known FOSS project. I include it here because it gives a step-by-step for overcoming the basic "connect my pHp project to a MSsql databse"  question. I recommend starting at the bottom of this article and working your way up, in reverse. I believe you will get there and will be a happy PGV user real soon. Good Luck !

    http://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_the_SQL_Server_2005_Driver_for_PHP_from_Microsoft

    Roland L

     
  • roland_l

    roland_l - 2010-04-01

    To Nick-v:

    Similar to the previous link from Fisharebest, here are some other posts regarding the "IIS and SQL2005server combo" in particular. As you can see, many work-arounds have been devised for these products and thus YMMV. Hope this helps more, keep us posted on your progress.

    http://php.net/manual/en/function.mssql-connect.php

    Roland L

     
  • Nick Veit

    Nick Veit - 2010-04-01

    Thanks for your advice and encouragement. After having spent many more hours on this my conclusion is:

    1) Why is it documented that this software supports MS SQL Server when none of the developers have access to it and it clearly contains code issues that prevent it from ever working. I would have appreciated not being mislead and wasting time.

    2) MS SQL Server, IIS etc. is relatively new with PHP. Drivers, Native Clients, FastCH, INI changes all make installation a nightmare. Further, the PHP config shows "-without-mssql" "-without-pdo-mssql" - I give up…am I supposed to have a c compiler to set these? When all this is resolved it will be worth looking again. I suspect most users want to use a free database like MySQL anyway.

    3) The software is designed for and proven with MySQL. After research I determined running MySQL (free) on the same box as MS SQL would not be a problem. The minimum install plus one command-line command to create a database got things working nicely. Why swim against the tide…

    I recommend strongly that MS SQL be avoided until at least the developers have proven it. MySQL works very well and the software appears really good !

     

Log in to post a comment.