Closed kosmic7 closed 2 years ago
Could you try connect with isql
to verify if the driver is installed correctly, for example isql -v -k 'DRIVER=ODBC DRIVER 18 FOR SQL SERVER;SERVER=database.windows.net;uid=;pwd=;... ...'
. You can modify the connection string after -k
for your environment. If you still getting the same error, try strace isql -v -k ...
, strace will give more information for debugging.
Thanks for the help! I tried the ISQL command and it connects OK with no error.
Oops did not mean to close this. Still looking high and low for an answer.
Thanks for the help! I tried the ISQL command and it connects OK with no error.
So the ODBC driver is working. Could you post some sample php code that you used to connect? You can also strace php to get more debug info.
Code I'm testing with is pretty basic:
$serverName = "xxxxx";
$connectionOptions = array(
"database" => "xxxxx",
"uid" => "xxxxx",
"pwd" => "xxxxx",
"TrustServerCertificate" => 1
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
Output:
Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1' : file not found [message] => [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1' : file not found ) )
While trying the strace, I see that it's working OK from the command line. I am only getting the error when running it via the web server. So most likely an Nginx config issue?
Just in case it matters... Nginx on my server was already installed and configured for the site I'm working on and is a bit complex. I didn't see an easy way to add the below (from MS install doc) but assumed it was already in place since PHP is working fine.
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
I tried enabling Trace in odbcinst.ini. I get results from that if I run my PHP code from the command line, but if I try in browser, nothing shows up in my trace file. For some reason it must not be seeing or using \etc\odbcinst.ini when running PHP on web server?
I tried enabling Trace in odbcinst.ini. I get results from that if I run my PHP code from the command line, but if I try in browser, nothing shows up in my trace file. For some reason it must not be seeing or using \etc\odbcinst.ini when running PHP on web server?
Do you have multiple PHP versions installed on that machine? Possibly Nginx is not using the right version.
Ah good idea there. I do have multiple versions of PHP installed. But running phpinfo() in browser is showing PHP version 7.4.29.
Hey I'm going to close this issue. I never did find a fix. Must be something with how hosted server is preconfigured. I decided redoing my app to use web services would be a better way to go. Much thanks for trying @absci!
Make sure you are using bash or zsh if bash: echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrc if zsh: echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.zshrc source ~/.zshrc
and make sure the python>=3.10 (if use)
I ran into this issue and found that Net::FTP was causing the problem. If I comment out the Net::FTP and Net::SFTP use statements, it works fine.
I've been trying to fix this for a week now but getting nowhere. Any help much much appreciated!!!
Ubuntu 18.04 PHP 7.4.29 Microsoft ODBC 18 PHP sqlsrv and pdo-sqlsrv version 5.10.0 (I think? not sure how to tell)
I installed MS ODBC and PHP-FPM drivers using instructions here: https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15
I'm getting this error when using sqlsrv_connect(): [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1' : file not found
I have verified that the file exists and that I have permission to access it:
I have checked library dependencies (although I did have to CD to the actual directory the .so was in for LDD to work?)
These files exist: