Does membership plugin support MS SQL

Does WPMU Dev and/or Membership plugin support MS SQL instead of MySQL?

When trying to add an initial membership level, the following error occurs, blocking success.

Warning: mysql_real_escape_string(): An attempt was made to access a socket in a way forbidden by its access permissions. in D:\home\site\wwwroot\wp-content\plugins\membership\membershipincludes\classes\membershipadmin.php on line 6831 Warning: mysql_real_escape_string(): A link to the server could not be established in D:\home\site\wwwroot\wp-content\plugins\membership\membershipincludes\classes\membershipadmin.php on line 6831

  • Vinod Dalvi

    Hi Michael,

    Welcome to the WPMU Dev community and thank you for your question.

    Does WPMU Dev and/or Membership plugin support MS SQL instead of MySQL?

    We have not tested it but i think it should work. If you face any problem using it with MS SQL then feel free to ask it.

    Find more information about supporting other databases by WordPress on the following pages.

    When trying to add an initial membership level, the following error occurs, blocking success.

    The error is occurring because the function mysql_real_escape_string is called without an active ext/mysql connection resource for the DB.

    Are you using any other database than Mysql?

    Could you please try using the following solution to resolve the issue?

    In the membership plugin file membership\membershipincludes\classes\membershipadmin.php on line number 6831 change the following code .

    $where[] = "level_title LIKE '%" . mysql_real_escape_string($filter['s']) . "%'";

    Kind Regards,
    Vinod Dalvi

  • Michael

    I am using Project Nami, which means I am using Microsoft Azure to host my WordPress instance using Microsoft's SQL 2012 database, not MySQL.

    The hyperlinks you refer to mostly discourage the use of non-mySQL databases. Is that the intent of WPMUDev to discourage use of non-mySQL databases? If so, I need to reconsider my options.

    That line of code implies the levels have been successfully created but at simply now showing up in the filter of the dialog, but I do not believe the levels are being created in the database itself (vs. a display filtering UI issue).

  • Vaughan

    Hi Michael,

    We actually support what the wordpress core natively supports, mainly mySQL.

    The issue with mysql_real_escape_string() is that this function is not an MSSQL function, and on SQL SErver, the escaping is done differently to mysql, therefore the function itself will not work with SQL Server.

    It looks like the plugin would actually need to be customized to work with SQL Server. This essentially would mean changing the mysql_real_escape_string() used in the queries to something compatible with MSSQL, maybe by changing the query itself and doing the escaping in a different manner such as parameterised queries, or with the prepare statement etc.

    I will need to ask the developers about this though, it could be a more complicated task than what I have mentioned above, and as we only natively support MySQL, we will not have tested our plugins with SQL Server at all, so there could be other issues unknown as yet. But hopefully the developers might be able to come up with a quick solution for you.

    Hope this helps

  • Hoang Ngo


    I hope you are well today.

    Membership using the WordPress API for accessing database. That's mean, if WordPress can play well with MS SQL, Membership will do.

    Unfortunately, Wordpress is only designed for MySQL, it does use ezSQL(which support various database including MS SQL) for querying, but, WordPress has many raw SQL queries, which only written under MySQL syntax.

    So this is a very big challenges, and I'm afraid switch database engine back to MySQL is a best solution :slight_frown:.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

  • Vaughan

    Hi michael,

    In case you still have issues with mysql real escape string (not sure if you solved your issue with Nami or not)

    But if you have any issues, could you try the following attached file.

    Replace /membershipincludes/classes/membershipadmin.php with the version from the attached zipfile.

    I haven't been able to test, but hopefully it should work ok.

    I have removed the mysql_real_escape_string() from the where clauses and modified the queries to use the Wpdb->prepare() function instead.

    Let us know how everything goes if you manage to sort this.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.