Support » Plugins » MySQL-Query don’t work

  • 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> ,
    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 :>


Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘MySQL-Query don’t work’ is closed to new replies.