i live in Vietnam, so My English is so bad, but i hope you know what i mean.
I want to setup a server that use : Apache, PHP, and Ms SQL server persional edition 2000.
But i only can connect Apache 2.0 and PHP 5.x
it run ok
But i don't know, the way that PHP can access MS SQL
how to set up
Help me, it is very nessecsary! hepl..........! Thanks every body :D

Dani AI

Generated

— the simplest way to think about this is: PHP can talk to SQL Server by one of three routes, and which one you pick depends on your PHP build and how old your SQL Server is. Several people here pointed in useful directions (for example on the PHP mssql functions and / on easy installer bundles), but those installer bundles do not automatically add a SQL Server driver. Below are concrete, practical steps and troubleshooting checks that fill the gaps in the thread.

If you use the legacy PHP mssql extension (common with PHP 5.x)

  • Enable php_mssql in php.ini (uncomment extension=php_mssql.dll) and restart Apache.
  • Put the DB-Library DLL (ntwdblib.dll) from a SQL Server client install where Windows/Apache can find it (Apache bin or System32). Wrong or missing ntwdblib.dll is the most common cause of failures.
  • Verify with phpinfo() that the extension loaded.
  • Quick test (example):
    <?php
    $link = mssql_connect('localhost', 'sa', 'password');
    mssql_select_db('YourDB', $link);
    $result = mssql_query('SELECT TOP 1 * FROM YourTable', $link);
    print_r(mssql_fetch_assoc($result));
    ?>

ODBC or Microsoft drivers (more reliable)

  • Create a System DSN in ODBC Data Sources (use the 32-bit ODBC admin if PHP/Apache is 32-bit).
  • Use php_odbc or PDO with an ODBC DSN:
    <?php
    $db = new PDO('odbc:YourDSN', 'user', 'pass');
    foreach ($db->query('SELECT * FROM YourTable') as $row) print_r($row);
    ?>
  • On Windows, the newer Microsoft sqlsrv/pdo_sqlsrv drivers are better for recent PHP versions but require installing the matching SQL Native Client/driver and the correct driver build for your PHP.

Troubleshooting checklist

  • SQL Server must allow SQL logins (Mixed Mode) if you use SQL credentials.
  • If remote, enable TCP/IP and open port 1433 or use server,port in the host string.
  • Match architectures: 32-bit PHP needs 32-bit drivers/ODBC. Mismatched VC/TS builds will prevent DLLs loading — check Apache error log for "unable to load" messages.
  • Post phpinfo() output and exact Apache/PHP build (VC version, thread-safety, 32/64-bit) when asking for more help — that information makes diagnosis much faster.

This fills in the practical steps missing from earlier replies and targets the common pitfalls that stop PHP 5 + Apache from connecting to SQL Server 2000.

Recommended Answers

All 8 Replies

hi,

if i got the point you don't know how to make a connection to MSSQL server with PHP, right?

so this will help you.

Yes, I see, i had read this document, i had practiced, but i were not successful, what a pity, but i will try again, thank for your support! have a nice day!

Thank's i need it have a good and nice day

I don't know if this is on the right lines but I use a package called XAMPP from the Apache Friends Web Site. This is a simple package that installs the following item:-

Apache HTTPD 2.2.6 + Openssl 0.9.8e
MySQL 5.0.45
PHP 5.2.4
PHP 4.4.7
phpMyAdmin 2.11.1
Zend Optimizer 3.3.0

Giving you the ability to run an apache server that will run php and mysql on a windows system. I use it to test (I am extremely new to php coding) my hit and miss attempts in php programming without having to upload to my web site first by using http://localhost/


Hope this helps, and if it's in the wrong area then please move it to a more relevant area.

Easy php, xammp also very easy to insall the php

please download Xamp from sourceforge.net and install it does thing automatic for u

It is wery easy. Just download this edition Xamp server, and inatall him.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.