Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - Turning on the MSSQL API Module

By: FYIcenter.com

(Continued from previous topic...)

How to Turn on the MSSQL API Module?

If you want to access SQL Server database with PHP scripts, the first thing you need to do is to turn on the MSSQL API Module as shown in this tutorial:

1. Prepare a single line script to test the MSSQL API Module:

<?php
  mssql_connect('LOCALHOST','sa','FYIcenter');
?>

Run the script, you should get:

Fatal error: Call to undefined function mssql_connect()
in C:\test\fyi-center.php on line 2

2. If you C:\php\php.ini does not exist, copy C:\php\php.ini-dist to C:\php\php.ini. Open C:\php\php.ini and remove (;) on the extension=php_mssql.dll setting:

;extension=php_mssql.dll
extension=php_mssql.dll

Run the script again, you may get:

PHP Warning:  PHP Startup: Unable to load dynamic library 
'C:\php5\php_mssql.dll' - The specified module could not 
be found.
 in Unknown on line 0

Fatal error: Call to undefined function mssql_connect()
in C:\test\fyi-center.php on line 2

3. Open C:\>\php\php.ini and change the extension_dir setting. The default setting is "./", but all extension module DLL files are in ./ext.

; Directory in which the loadable extensions (modules)...
; extension_dir = "./"
extension_dir = "./ext"

Run the script again, you may still errors. But it is not related to MSSQL API Module any more.

Warning: mssql_connect(): Unable to connect to server:
LOCALHOST in C:\test\fyi-center.php on line 2

(Continued on next topic...)

  1. How To Download and Install PHP on Windows?
  2. How To Check Your PHP Installation?
  3. What Do You Need to Connect PHP to SQL Server?
  4. How to Turn on the MSSQL API Module?
  5. What Is Wrong with SQL Server Client Libarary DLL, ntwdblib.dll?
  6. What Happens If ntwdblib.dll Is Missing on Your Machine?
  7. Where to Find ntwdblib.dll Version 2000.80.194.0?
  8. How To Connect with Different Port Numbers?
  9. What Are Commonly Used MSSQL Functions in PHP?
  10. How To Disconnect from a SQL Server using mssql_close()?
  11. How To Select an Exiting Database using mssql_select_db()?
  12. How To Execute a SQL Statement using mssql_query()?
  13. How To Retrieve Error Messages using mssql_get_last_message()?
  14. How To Turn Off Warning Messages during PHP Execution?
  15. How To Receive Returning Result from a Query?
  16. How To Loop through Result Set Objects using mssql_fetch_array()?
  17. How To Retrieve Field Values using mssql_result()?
  18. How To List All Field Names in the Result Set using mssql_field_name()?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...