Home arrow PHP arrow Page 5 - Executing Microsoft SQL Server Stored Procedure from PHP on Linux

Executing Microsoft SQL Server Stored Procedure from PHP on Linux

Learn how to setup, install and configure Apache and PHP on a Linux box to execute MS SQL stored procedures. This extensive article takes you through an in-depth look on how to achieve your ideal environment.

Author Info:
By: Jack Zhang
Rating: 4 stars4 stars4 stars4 stars4 stars / 33
October 20, 2003
  1. · Executing Microsoft SQL Server Stored Procedure from PHP on Linux
  2. · Preparation
  3. · Installing the Apache Web Server
  4. · Installing the Apache Web Server, Cont'd
  5. · Installing FreeTDS
  6. · Modify the PHP Source Code
  7. · Modify the PHP Source Code, Cont'd
  8. · Executing MS SQL Server Procedures from PHP
  9. · Conclusion

print this article

Executing Microsoft SQL Server Stored Procedure from PHP on Linux - Installing FreeTDS
(Page 5 of 9 )

From the /public folder, issue:

cd FreeTDS-0.61.2

This will change our working directory to FreeTDS.  According to the PHP documentation, if we want to use FreeTDS to connect to a MS SQL Server, we need to append --enable-msdblib to the configure command.  For detailed information, you can issue the following command:

./configure --help

This is what I used for the installation of FreeTDS:

./configure  --prefix=/usr/local/freetds --sysconfdir=/usr/local/ freetds --with-tdsver=7.0 --enable-msdblib --enable-threadsafe --enable-sybase-compat

Since there is less dependency on the operating system, it is easy to pass this step without any error.  Next, we compile the module tree, issue the following:


And install FreeTDS by issuing:

make install

After these 2 steps, you will find a new folder /usr/local/freetds, which contains the new files weve just installed.  Lets test our installation, change directory to this folder, and issue:

cd /usr/local/freetds

Edit freetds.conf:

gedit freetds.conf

I have a windows box running MS SQL Server 2000 on it.  The machine name is home2k with IP address  Append the following part to FreeTDS.conf, and save it:

host =
port =1433
tds version = 7.0

Change to the bin folder under /usr/local/freetds,  and issue:

tsql S home2k U sa P

If you see 1> coming out,  that means the connection to MS SQL Server is        established,  you can test further via sending an SQL statement to the SQL Server like the following screen, then exit using the tsql command.

blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials