iTEYE

Installing MSSQL Module for PHP on Mac OS X

25 июля 2013

For two days I try to connect my php script on to SQL Server 2000. All my attempts failed until I use dtruss. Finally I can connect to from with .

At first i want to say Thank you Xavier Perseguers for his article MSSQL Support for PHP.

Below I quote part of his article with my edits and comments.

On Mac OS X, you would use MacPorts and package php5- and :

Then edit/create file /opt/local/etc//tds.driver.template:

Then prepare your DSN into /opt/local/etc//tds.dsn.template:

Edit file /opt/local/etc//freetds.conf:

Register the driver and your DSN:

Those commands are the official way of modifying files /opt/local/etc/odbcinst.ini and /opt/local/etc/.ini but you may of course modify them manually.

Testing the System

It is possible to test the connection with isql:

But it never worked for me until I found the underlying cause (Google was of no help although many users had this problem). I always got following error:

[S1000][unixODBC][][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

The trick is to export variable ODBCINI:

Another test you may perform before going on configuring your TYPO3 website is with a simple PHP script:

If you had to export the ODBCINI variable, you likely will have to do it too for 2, otherwise TYPO3 will fail to connect to your database with the same error message.

Edit file /opt/local/2/bin/envvars and add this to the end:
Or /Applications/MAMP/Library/bin/envvars if you use MAMP

Then restart .

PHP Configuration

Last but not least, edit your php.ini file:

and this in the section:

technology, , , , , , , , , ,

Comments

Иван 17 марта 2014 • 12:49

Спасибо, только подскажите, на какой (или каких) версии PHP вы это реализовывали?
Очень буду благодарен за оперативный ответ.

Eugene 14 апреля 2014 • 15:46

Иван, прошу прощения за задержку с ответом. 5.3.14 и 5.4.4

Leave a Reply

Скидки до 5% на заказ хостинга!

Сайт работает на быстром VPS/VDS хостинге от FASTVPS