Title: Connecting to external SQL Server with a plugin
Last modified: August 19, 2016

---

# Connecting to external SQL Server with a plugin

 *  Resolved [Joe Casabona](https://wordpress.org/support/users/jcasabona/)
 * (@jcasabona)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/connecting-to-external-sql-server-with-a-plugin/)
 * Hello! I’m trying to connect to a separate SQL Server Database from within my
   plugin (the data is already in that database) so I am trying to do so this way:
 *     ```
       $dbh= mssql_connect($host, $user, $password) or die ('I cannot connect to the database because: ' . mssql_get_last_message());
       		mssql_select_db($database) or die ('I cannot connect to the table because: ' . mssql_get_last_message());
       ```
   
 * However, I’m getting an unable to connect error. When I run the same code outside
   of a wordpress plugin in the wordpress directory, I connect fine and can display
   the data.
 * Does WordPress have some option I need to enable to connect to a different database
   not using $wpdb? Is it blocked completely?
 * Thanks!
 * Joe

Viewing 1 replies (of 1 total)

 *  Thread Starter [Joe Casabona](https://wordpress.org/support/users/jcasabona/)
 * (@jcasabona)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/connecting-to-external-sql-server-with-a-plugin/#post-1595904)
 * Update: there is no issue. It was a variable issue due to tired eyes.
 * So for future reference- you should be able to connect to an external SQL Server
   within a WordPress plugin with no problems, assuming you have the proper DLL 
   installed.

Viewing 1 replies (of 1 total)

The topic ‘Connecting to external SQL Server with a plugin’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [mssql](https://wordpress.org/support/topic-tag/mssql/)
 * [SQL Server](https://wordpress.org/support/topic-tag/sql-server/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Joe Casabona](https://wordpress.org/support/users/jcasabona/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/connecting-to-external-sql-server-with-a-plugin/#post-1595904)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
