+## Driver version or file name
5.2.0
+## SQL Server version
SQL Server 2017 on Docker
+## Client operating system
MacOS 10.12.6
+## PHP version
Tried both 7.0.x and 7.2.x
+## Microsoft ODBC Driver version
unixODBC 2.3.6
+## Table schema
Not apply
+## Problem description
Fatal error: sqlsrv_connect: Unknown exception caught.
+## Expected behavior and actual behavior
sqlcmd connects successfully
php driver installed correctly as i can see on phpinfo()
but i can't connect using sqlsrv or pdo.
+## Repro code
Followed example inside this tutorial: https://www.microsoft.com/en-us/sql-server/developer-get-started/php/mac/step/2.html
And this: https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017
No success.
@luizzz Could you provide a repro script and the exact output you see so that we know exactly what you are trying to do?
Well, just tried on my MacBook Pro and works flawlessly.
Same configuration above except MacOS 10.13.4 and PHP Version 7.2.2.
On my MacOS 10.12.6 doesn't work.
Test code:
<?php
$serverName = "187.28.xx.xxx";
$connectionOptions = array(
"Database" => "*********",
"Uid" => "user_homolog",
"PWD" => "*********"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn)
echo "Connected!"
Output:
Fatal error: sqlsrv_connect: Unknown exception caught on line 9
Ok, could you provide an ODBC trace for this script? To get a trace, add "TraceOn"=>true, "TraceFile"=>"trace.log" to your connection options, and add the following lines to your /etc/odbcinst.ini file:
[ODBC]
Trace=yes
TraceFile=<path to trace.log>
and run your script. Please run the trace for when it fails and when it works so we can compare the two.
I'm experiencing the same issue connecting to a remote sql srv 2012: adding to ~/.zshrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
as stated here https://github.com/Microsoft/msphpsql/issues/161#issuecomment-384662270 make the connection from cli works
I'm experiencing the same issue connecting to a remote sql srv 2012: adding to ~/.zshrc
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8as stated here #161 (comment) make the connection from cli works
in my case .bash_profile
Most helpful comment
I'm experiencing the same issue connecting to a remote sql srv 2012: adding to ~/.zshrc
as stated here https://github.com/Microsoft/msphpsql/issues/161#issuecomment-384662270 make the connection from cli works