faqts : Computers : Programming : Languages : PHP : Installation and Setup : Databases

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 7 people (57%) answered Yes
Recently 4 of 7 people (57%) answered Yes

Entry

How do I enable the Microsoft SQL extension in PHP? Step by Step

May 23rd, 2005 09:27
Willie duMaine, Chris A, http://www.php.net/manual/en/ref.mssql.php


The following instruction came from a user contributed note in Microsoft
SQL Server Functions section of PHP on-line manual
(http://www.php.net/manual/en/ref.mssql.php).
One note I would like to add that tds version 7.0 still works for SQL
Server 2000, but you may loose some functionality that is in version
8.0.  However, I did solve some connection problems by using tds version
7.0 with SQL Server 2000.  Hope this helps.
---START---
User Contributed Notes
Microsoft SQL Server Functions
marcos1979ar at yahoo dot com dot ar
10-Jun-2004 06:07
Red Hat 9.0  Freetds 0.62.3  Apache 2.0.49  PHP 5.0.ORC3
Instucction, that premit connect a server Linux with a server Windows
2000 Server with SQL Server.
INSTALLING FREETDS
1-.  Download freetds -> www.freetds.org
2-.  tar -zxvf freetds-stable-tgz
3-.  cd freetds-0.62.3
4-.  ./configure --prefix=/usr/local/freetds --with-tdsver=8.0
--enable-msdblib --enable-dbmfix --with-gnu-ld
Note:  tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0
5-.  make
6-.  make install
7-.  /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>
Note: For default User SQL is    sa    and the it have not password
For example: /usr/local/freetds/bin/tsql -S 198.168.100.2 -U sa
8-.  Add the next text in freetds.conf ( /usr/local/freetds/etc )
[TDS]
host = <ip of the Server with Sql>
port = 1433
tds version = 8.0
Note: If you use SQL 2000 then tds version = 8.0
if you use SQL 7.0 then tds version = 7.0
9-.  Add the next text in the file /etc/ld.so.conf
/usr/local/freetds/lib
INSTALLING  APACHE
1-.  Download apache  www.apache.org
2-.  tar -zxvf httpd-2.0.49.tar.gz
3-.  cd httpd-2.0.49
4-.  ./configure --prefix=/etc/httpd --enable-so
5-.  make
6-.  make install
7-.  Configure the file  -> httpd.conf ( /etc/httpd/conf/httpd.conf )
8-.  Probe the apache: /etc/httpd/bin/apachectl start
/etc/httpd/bin/apachectl stop
INSTALLING  PHP
1-.  Download the PHP in this site (www.php.net)
2-.  tar -zxvf php-5.0-ORC3.tar.gz
3-.  cd php-5.0-ORC3
4-.  ./configure --with-apxs2=/etc/httpd/bin/apxs --enable-versioning
--with-mssql=/usr/local/freetds --disable-libxml
5-.  make
6-.  make install
7-.  cp php.ini-DIST /usr/local/lib
8-.  Add the next line in /etc/httpd/conf/httpd.conf
AddType application/x-httpd-php .php
TESTING
<html>
<body>
<?php
$con = mssql_connect ("<ip of the server SQL>", "sa", "");
mssql_select_db ("<Data Base>", $con);
$sql= "SELECT * FROM <Table>";
$rs= mssql_query ($sql, $con);
echo "The field number one is: ";
echo mssql_result ($rs, 0, 0);
mssql_close ($con);
?>
</body>
</html>
---END---