I have SQL Anywhere 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
At 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 3
I've tried defining ODBCHOME=/home/vagrant in /etc/environment (and rebooting), but that doesn't have any effect.

What am I missing here?

asked 11 Jan '16, 19:44

Terry%20Wilkinson's gravatar image

Terry Wilkinson
accept rate: 25%

edited 12 Jan '16, 09:04

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?

permanent link

answered 12 Jan '16, 14:13

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
accept rate: 32%

converted 12 Jan '16, 19:13

Mark%20Culp's gravatar image

Mark Culp

Yes, that was it. I'm still new to the way linux uses accounts, but it appears that, by default, php5-fpm launches under www-data. When I changed that to vagrant, it finds the .odbc.ini file and the ODBC connection works.

Thanks for your help.

(12 Jan '16, 19:05) Terry Wilkinson
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 11 Jan '16, 19:44

question was seen: 3,123 times

last updated: 12 Jan '16, 19:08