Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP and MS SQL Connectivity

Status
Not open for further replies.

meenakshidhar

Programmer
Oct 19, 2001
77
MY
Hi All,
Can anybody plss tell me how to connect PHP and MS SQL Server database...i have WIN98 machine with apache 1.3.2.9 and php 4.3.4 installed...
1. Enable mssql extensions in php.ini
2. Add php_mssql.dll to php.exe working directory

My code is
<?
$msconnect=mssql_connect(&quot;1.1.1.1&quot;,&quot;username&quot;,&quot;pass&quot;);
$msdb=mssql_select_db(&quot;dbname&quot;,$msconnect);
$msquery = &quot;select * from table1&quot;;
$msresults= mssql_query($msquery);
while ($row = mssql_fetch_array($msresults)) {
echo &quot;<li>&quot; . $row['fieldname']. &quot;</li>\n&quot;;
}
?>
The error which i m getting is &quot;Warning: mssql_connect(): Unable to connect to server: serverip&quot;

Urgent help needed..

Regards
Meenakshi Dhar
 
Your host needs to have the port indicated

$msconnect=mssql_connect(&quot;1.1.1.1,1433&quot;,&quot;username&quot;,&quot;pass&quot;);
 
i am changing...things...going on linux 7.3 n installing php on it..i mean compiling php 4.3.0 now i need to give support for mssql...how can i do it...
 
First, compile and install FreeTDS.

Second, compile PHP with support for MSSQL using the --with-mssql=<directory> where <directory> is where you installed FreeTDS.

Then you will have to configure freetds.conf (usually installed in /etc to set up TDS connection parameters for connecting to your MSSQL.

Information is available:
Want the best answers? Ask the best questions: TANSTAAFL!!
 
i have installed FreeTDS...now i require both MySQL and MSSQL compiled with php...i m using MySQL 3.3.49, mysql-server-3.3.49, php 4.2.3, php-mssql-4.3.3...

could u plss tell me which versions of php, mysql and mssql should i use...
 
With the open-source software, you should be using the latest production release. For PHP, that's version 4.3.4. For MySQL, 4.0.17

For MSSQL...with Mi&cent;ro$oft's licensing, use what you have. I know from personal experience that FreeTDS will communicate with MSSQL 6.5 and 7.0, and I have it on good authority that FreeTDS will work with MSSQL 2000.

It looks, though, like you are using precompiled binaries for a lot of your code. For two reasons, I generally recommend installing PHP from source code. First, you can get the latest version installed whenever it is released -- with RPMs, for example, you may have to wait a while before someone packages a new version for your platform. Second, you can control exactly what features you enable and disable in PHP -- a lot of features I use with PHP (image creation, etc) are not enabled in a lot of binary distributions of PHP.

With MySQL, use the precompiled binaries MySQL provides.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top