WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Connecting to external SQL Server with a plugin (2 posts)

  1. Joe Casabona
    Member
    Posted 4 years ago #

    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

  2. Joe Casabona
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic