none
unable to load php_sqlsvr.dll

    Question

  • Hi,

    I am unable to get PHP to load the drivers from the package.

    I have tried adding the followings in php.ini (locate in the same path of php binary):
    extension=php_sqlsrv.dll

    When I try to verify php loaded module in prompt command, with this instruction php -v
    then I obtain this result:

    PHP Warning:  PHP Startup: Unable to load dynamic library 'c:\php\ext\php_sqlsrv.dll' - unable to find specified module.
     in Unknown on line 0
    PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


    The path is correct and the php_sqlsvr.dll is into this directory.
    The SQL Native Client have also been installed.

    My configuration is:
    OS is Vista 32bit Version,
    PHP 5.2.5

    What have I missed?
    Friday, January 11, 2008 1:56 PM

All replies

  • Interesting.  I myself have loaded it within PHP 5.2.5.  The first thing I can think of is that I believe we shipped two dlls, php_sqlsrv.dll for non thread safe, and php_sqlsrv_ts.dll for thread safe versions.  I would try php_sqlsrv_ts.dll.

     

    If that doesn't work, what does the log file tell you?  Does it give a reason?  It should tell you some information at least about what routines were called.

     

    Jay

    Friday, January 11, 2008 6:53 PM
  • Thank you for reply.

    I tried the php_sqlsvr_ts.dll and when I write 'php -v' in the prompt, I obtain:

    C:\> php -v
    globals initialized
    sqlsrv: entering minit
    sqlsrv: exitting minit
    PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    globals destroyed


    I suppose that result is correct!

    But when I try the connection to SQL Server 2005 with the following code (I found this code in php_sqlsvr_API_ref.doc):

    <?php

    $serverName = "myServer";

    $conn = sqlsrv_connect($serverName);



    if( $conn )

    { echo "Connection opened.<br/>"; }

    else
    {

    foreach( sqlsrv_errors() as $error )

    {

    echo "SQLSTATE: ".$error['SQLSTATE']."<br/>";

    echo "Code: ".$error['code']."<br/>";

    echo "Message: ".$error['message']."<br/>";

    }

    }

    ?>


    the result of this code exeution is:
    Fatal error: Call to undefined function sqlsrv_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\conn.php on line 2

    I have read your reply for consulting the log files, for read the cause of problem, but where is the log file??? :-)

    The Apache function correctly.
    When I execute the php_info() function I don't have any reference to SQL Server...is this the problem? and if yes how I can resolve this?

    thanks
    Monday, January 14, 2008 9:39 AM
  • I'm having a similiar issue.  I get "call to undefined function sqlsrv_connect()" if I load my PHP file from inetpub\wwwroot

    I get a little farther if I copy the PHP sample code into the same folder as php5ts.dll and php_sqlsrv_ts.dll

    C:\php>php -v
    globals initialized
    sqlsrv: entering minit
    sqlsrv: exitting minit
    PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    globals destroyed

    C:\php>php mssql.php
    globals initialized
    sqlsrv: entering minit
    sqlsrv: exitting minit
    <!--=====================================================================
      This file is part of a Microsoft SQL Server Shared Source Application.
      Copyright (C) Microsoft Corporation.  All rights reserved.

    THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
    KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
    PARTICULAR PURPOSE.
    ======================================================= *-->

    <!--Note: The presentation formatting of the example application is -->
    <!--intentionally simple to emphasize the SQL Server data access code.-->
    <html>
    <head>
    <title>AdventureWorks Product Reviews</title>
    </head>
    <body>
    <h1 align='center'>AdventureWorks Product Reviews</h1>
    <h5 align='center'>This application is a demonstration of the Microsoft SQL
                       Server 2005 Driver for PHP.</h5><br/>
    sqlsrv_connect: entering
    handle_error: entered for function sqlsrv_connect
    handle_errors_and_warnings: entering
    SQLGetDiagRec returned 100
    handle_errors_and_warnings: exitting
    Error information: <br/>
    C:\php>


    Tuesday, February 12, 2008 5:06 AM
  • I got it to work!

    In my PHP script I had to use the actual name of my computer instead of (local) to identify my SQL instance (e.g. MYCOMPUTER\SQLEXPRESS instead of (local)\SQLEXPRESS)

    Then tweak a few permissions in the AdventureWorks db and now it works great.

    Hope this helps



    Tuesday, February 12, 2008 5:35 AM
  • great! what about PHP 5.2.8 that has no such file containing

    the string sqlsrv and no mention in php.ini

     

    error:

    Fatal error: Call to undefined function sqlsrv_connect() in C:\Inetpub\wwwroot\sqlsrv1.php on line 13

    code from msdn site:
     

    <?php
    /*Connect to the local server using Windows Authentication and specify
    the AdventureWorks database as the database in use. To connect using
    SQL Server Authentication, set values for the "UID" and "PWD"
     attributes in the $connectionInfo parameter. For example:*/

    $uid = "sa";
    $pwd = "K^a_t^e_a_u_X_3141";
    // $connectionInfo = array("UID" => $uid, "PWD" => $pwd);
    $serverName = "(local)";
    // $serverName = "LANDON\SQLEXPRESSLMKIII";
    $connectionInfo = array( "Database"=>"logbookid");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    if( $conn )
    {
         echo "Connection established.\n";
    }
    else
    {
         echo "Connection could not be established.\n";
         die( print_r( sqlsrv_errors(), true));
    }

    //-----------------------------------------------
    // Perform operations with connection.
    //-----------------------------------------------

    /* Close the connection. */
    sqlsrv_close( $conn);
    ?>

     

     


    • Edited by landon1 Wednesday, March 30, 2011 5:30 PM typo
    Saturday, December 20, 2008 12:55 AM
  • The dll wasn't loaded in this case.  Make sure the DLL is somewhere that php can find and that you have configured PHP to try to load it.
    This post is provided 'as is' and confers no express or implied warranties or rights.
    Thursday, January 08, 2009 1:44 AM
    Moderator