I have SQL Anywhere 17.0.0.1062 running with PHP 5.5 under Ubuntu 14.04. It's working fine and I can connect successfully using $conn = sasql_connect( "Server=mydb;DBN=mydb;UID=DBA;PWD=xxx" );However, I now want to setup it up to work with ODBC. First I created an ODBC connection with the command: dbdsn -w mydb -c "Server=mydb;DBN=mydb;UID=DBA;PWD=xxx"That successfully creates a .odbc.ini file in my home directory ( /home/vagrant ).
[ODBC Data Sources] mydb=SQLAnywhere 17.0 [mydb] UID=DBA PWD=xxx ServerName=mydb Driver=/opt/sqlanywhere17/lib64/libdbodbc17.soAt this point I can use SQL Central and "Connect with an ODBC Data Source". That works. However using PHP, the statement: $conn = sasql_connect( "DSN=mydb" );fails to connect and gives the error Warning: sasql_connect(): SQLAnywhere: [-95] Parse error: Cannot find .ini file in /usr/share/nginx/html/sasql_test.php on line 3I've tried defining ODBCHOME=/home/vagrant in /etc/environment (and rebooting), but that doesn't have any effect.
What am I missing here? |
There is something about this that doesn't add up correctly. The .odbc.ini is clearly present since SQL Central can find it and the search for that will automatically include your home directory. Also since PHP can connect without it this does not seem to related to the environment not being set up correctly; so the generated sa_config.[csh|sh] must have been sourced already. Maybe this has something to do with they way you launch your PHP runtime? Yes, that was it. I'm still new to the way linux uses accounts, but it appears that, by default, php5-fpm launches under Thanks for your help.
(12 Jan '16, 19:05)
Terry Wilkinson
|