Solved

How to connect Linux-PHP to MS-SQL Server?

Posted on 2009-03-28
10
2,482 Views
Last Modified: 2013-12-12
Hi,

I have a Fedora 9 box where apache, php, mysql .. are running okay. I need to connect from this machine using php to a MS-SQL Server that is in same network. To do this we were trying to install free tds as per article - http://www.linuxjournal.com/article/6636

but while configuring:
[root@localhost]# tar xvfz freetds-0.60.tgz
[root@localhost]# cd freetds-0.60
[root@localhost]# ./configure --with-tdsver=7.0 --with-unixodbc
but this will show a error message -
"configure: sql.h file not found"

I have googeled a lot still dont know how to resolve this sql.h issue or how to get the file.

Will highly appreciate any help on this .. or if any alternative way to connect to MS-SQL server is available .

Thanks and regards,
Sabbir
0
Comment
Question by:Sabbir456
10 Comments
 
LVL 12

Expert Comment

by:udayakumarlm
Comment Utility
you will require the FreeTDS Library from http://www.freetds.org/
you can find the follwoing link contains a step by step of setting up and useing MSSQL in PHP
read the requirements session and more details at http://in.php.net/manual/en/book.mssql.php
0
 

Author Comment

by:Sabbir456
Comment Utility
To udayakumarlm:

1)  Yes I have downloaded the Freetds .. and while try to configure it on my fedora 9

[root@localhost]# ./configure --with-tdsver=7.0 --with-unixodbcbut this will show a error message - "configure: sql.h file not found"

please refer to my problem details posted earlier.

2) The other link you provided only refer to connecting form windows-php to MSSQL but I need to connect to Linux-php tp MSSQL


0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
you can try:
HOWTO: Connect RubyOnRails on Fedora Linux to SQL2005
http://www.not404.com/Howto_SQL2005_From_RailsOnFedora
 
Accessing Microsoft SQL Server (mssql) from PHP under Apache on Unix or Linux
http://www.easysoft.com/developer/languages/php/sql_server_unix_tutorial.html
 
---
also see
"configure: sql.h file not found"
http://lists.ibiblio.org/pipermail/freetds/2008q3/023734.html
http://archives.devshed.com/forums/development-94/tdsodbc-h-26-sql-h-no-such-file-or-directory-982422.html
0
 
LVL 29

Expert Comment

by:Michael W
Comment Utility
Since your running Fedora 9, have you tried 'yum install freetds'?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Accepted Solution

by:
Michael W earned 500 total points
Comment Utility
Or better yet...

The php-mssql package contains a dynamic shared object that will add MSSQL database support to PHP. It uses the TDS (Tabular DataStream) protocol through the freetds library, hence any database server which supports TDS can be accessed.

http://rpmfind.net/linux/rpm2html/search.php?query=php-mssql

Try: yum install php-mssql
0
 

Author Comment

by:Sabbir456
Comment Utility
Hi,

I am trying your suggested solutions .. will get back with results. Thanks a lot.

regards,
Sabbir

0
 

Author Comment

by:Sabbir456
Comment Utility
hi mwecomputers,

both yum install freetds and  yum install php-mssql worked fine.


was able to connect to SQL Server 2005 using mssql_connect
Thanks ...... a lot.

Sabbir


0
 
LVL 29

Expert Comment

by:Michael W
Comment Utility
Glad I could help.

-- Michael
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
The viewer will learn how to dynamically set the form action using jQuery.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now