Support » Plugins and Hacks » querying the db from a plugin problem

  • alalex

    (@alalex)


    I’m developing a plugin and I am completely unable to insert things to the db. I’ve tried I think everything and nothing!

    There is a main file with the activation function that creates a table in the db (And it works fine)

    Then in the plugin page there is a form that I use to add rows to the db. But it doesn’t seem to work…
    Here is the Insert code:

    $insert = "INSERT INTO " . $table_name .
    " (name, selector, bg, color, font, apply) " .
    "VALUES ('$name','$selector'.'$bg','$color','$font','$apply')";
    
    $results = $wpdb->query($insert);

    The $table_name is perfectly fine. There is also the field id at the beginning, but it’s set to auto_increment so there is no need to put it there.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    So the table name has the $table_prefix as part of the string?

    MichaelH

    (@michaelh)

    Also shouldn’t that be a comma between $selector and $bg

    "VALUES ('$name','$selector'.'$bg','$color','$font','$apply')";

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘querying the db from a plugin problem’ is closed to new replies.