简体   繁体   中英

Can not connect to SQL SERVER Using Latest Drivers for PHP

I have been trying to figure out which dll and how to use it to connect to sql server.

It was much easier using the old php_mssql.

I am using Xampp on WinXP Pro SP3. I have been unable to figure out how to connect, i have search the manual, and none of the command's work.

I get PDO Error Driver Not Found

extension-php_pdo_sqlsrv_54_ts.dll extension=php_sqlsrv_54_ts.dll

I realized that I must use the SQLSERV 2.0 Drivers. But which dll is the correct one? And what syntax must I use to connect and run queries?

Thank you.

One way of doing this is using FreeTDS for Windows

I am assuming you have PHP >5.3 Download this http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip

Add this line to your php.ini extension=php_dblib.dll

You will also need to make a file called freetds.conf in the root directory of your PHP installation.

It should look something like this:

[global]
     host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)
     port = 1433
     client charset = UTF-8
     tds version = 8.0
     text size = 20971520

Restart Apache and try running this script:

<?php
    $link = mssql_connect('localhost', 'db_user', 'db_password');
    if(!$link) {
        echo'Could not connect';
        die('Could not connect: ' . mssql_error());
    }
    echo'Successful connection';
    mssql_close($link);
?>

hit me up on fb if this does not work ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM