Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:05:03+00:00 2026-06-12T04:05:03+00:00

I have Apache 2.2.16 and PHP 5.4.3 on a Linux Debian 6 x64. To

  • 0

I have Apache 2.2.16 and PHP 5.4.3 on a Linux Debian 6 x64.

To install the MSSQL Server’s Native ODBC Driver for Linux, I use the following instructions:
http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/

I configured my odbc.ini file this way:

[mydsn]
Driver      = SQL Server Native Client 11.0
Database    = datbase
Server      = xxx.xxx.xxx.xxx,port

and my odbcinst.ini this way:

[SQL Server Native Client 11.0]
Description=Microsoft SQL Server ODBC Driver V1.0 for Linux
Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=1

To test, I run the following command:

$ isql -v mydsn dbusername dbpassword

And I got success:

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

Then, a use phpize to install unixODBC on PHP 5.4, using this:
(The first command, ln -s …, is used because ./configure can’t find the headers of php on the default location)

$ sudo ln -s /usr/include/php5 /usr/include/php
$ phpize
$ ./configure --with-pdo-odbc=unixODBC && make && make test
$ sudo make install

On my phpinfo() I get:

PDO support - enabled
PDO drivers - odbc

PDO Driver for ODBC (unixODBC) - enabled
ODBC Connection Pooling        - Enabled, strict matching

Now it’s time to test everything on a PHP 5.4 script:

<?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    $conn = new PDO('odbc:DSN=mydsn;UID='.$usr.';PWD='.$psw);

    $query = 'select * from my_table'; 
    $stmt = $conn->prepare($query);
    $stmt->execute();
    while ($row = $stmt->fetch()) {
        echo "<pre>";
        print_r($row);
        echo "</pre>";
    }
?>

But it doesn’t work… I got this error message:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01000] SQLDriverConnect: 0 
[unixODBC][Driver Manager]Can't open lib '/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0' : file not found' 
in /var/www/testemssql.php:17 
Stack trace: 
#0 /var/www/testemssql.php(17): PDO->__construct('odbc:DSN=mydsn...') 
#1 {main} thrown in /var/www/testemssql.php on line 17

So my question is: what is happen? What configuration I’m missing?
How to set up correctly the MSSQL Server’s Native ODBC Driver on Linux and PHP 5.4?

Ps.: When I try to use the odbc_connect() PHP says the function doesn’t exist.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:05:04+00:00Added an answer on June 12, 2026 at 4:05 am

    MSSQL Server’s Native ODBC Driver for Linux has a bug on it

    To connect MS SQL Server correctly, use FreeTDS
    See more details in : PHP 5.4 on Linux: How to connect with MS SQL Server 2008?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed native apache and mysql,php in my linux server. I tried a
I have a Linux server Debian 6, with Apache 2.2 and PHP 5.4 installed.
I have a linux server running ubuntu 10.10 maverick with apache and php installed,
I have a local install of Apache / MySQL and PHP on Fedora Linux.
I have installed PHP, Apache in my Linux server. http://localhost/index.htm displaying correctly. To test
I have a gentoo linux amd64 server that runs apache 2.2.22 with PHP 5.4.6.
On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts
I have a LAMP (Linux/Apache/MySQL/Php) application that I should release soon. Even if I've
We have a custom PHP/MySQL CMS running on Linux/Apache thats rolled out to multiple
I have a shared-hosting account at GoDaddy, which includes LAMP (Linux, Apache HTTP Server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.