Forums

Problem Accessing Custom MySQL Database (6 posts)

  1. drake77
    Member
    Posted 4 years ago #

    Hi,

    I'm fairly new to writing WordPress plugins and had a question about accessing a MySQL database.

    My plugin consists of some php code that displays data from a MySQL database. When I try to access my database, however, it breaks WordPress. I get errors like these:

    [08-May-2008 04:00:32] WordPress database error Table 'MyDatabase.wp_comments' doesn't exist for query SELECT DISTINCT ID, post_title...

    It appears that when I try to access my database, WordPress attempts to find its tables in my database as well, instead of looking in the WordPress database.

    I need to be able to access my database, but don't want to break WordPress in the process.

    Thank you in advance.

    Drake

  2. Michael Torbert
    WordPress Virtuoso
    Posted 4 years ago #

    Is your stuff actually in a separate database, or in separate tables within the WordPress database?

  3. drake77
    Member
    Posted 4 years ago #

    Hi and thanks for the reply. My tables are in a database that is separate from the WordPress database.

  4. Michael Torbert
    WordPress Virtuoso
    Posted 4 years ago #

    Are you using the WordPress database class? You need to just make a new SQL connection.

  5. drake77
    Member
    Posted 4 years ago #

    Just need to make a connection to the db without disrupting WP and it's connection.

  6. Michael Torbert
    WordPress Virtuoso
    Posted 4 years ago #

    Right. Then do what I just said. Make a new SQL connection. Don't use wpdb.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.