WordPress.org

Forums

MySQL-Query don't work (2 posts)

  1. TechnoLogiY
    Member
    Posted 6 years ago #

    Heyho guys.

    I'm creating a plugin for newsletter. The users can subscribe to the newsletter in the sidebar, where an AJAX sends the email to a php-script in the plugin-folder. The Php-file shall insert this email into a database which is created in the admin-menu.

    Im using this command:

    $query = $wpdb->query("INSERT INTO 'newsletter_mails' (
    <code>id</code> ,
    <code>mail</code> ,
    <code>status</code>
    )
    VALUES (
    NULL , '".$_GET["mail"]."', 'active'
    );");

    (The code is correct, but the backticks make it a little different.. :P)

    And i get this error:
    Unknown MySQL server host 'DB_HOST' (11001)

    Please help me so i can go on with my plugin :>

    Ciao!

  2. Michael Torbert
    WordPress Virtuoso
    Posted 6 years ago #

    Apparently, MySQL is trying to connect to a MySQL database on a host called DB_HOST.
    Somewhere along the way, you surely told it to do this. Since we can't see the rest of your code, I can only guess what you may have exactly that's causing this. Possible causes: db_host isn't defined in wp-config.php (I would like to assume you would know if this is the problem since you'd have a difficult time using WordPress if that's the case), you tried to make your own connection using DB_HOST but instead used 'DB_HOST,' or something similar.
    I would grep -i db_host in your plugin files. Then I suspect you'll see the issue. I would bet it has to do with not using your quotes correctly.

Topic Closed

This topic has been closed to new replies.

About this Topic