Hello There, Guest! › Register

Hide Content 1.4 released.
Looking for a custom plugin for your site? Ask here for a quote.

problems with query inside activation in plugin

My settings might be wrong but this is what happens:
MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1146 - Table 'mybb_db.mybb_mybb_settinggroups' doesn't exist
    INSERT INTO mybb_mybb_settinggroups (`gid`,`name`,`title`,`description`,`disporder`,`isdefault`) VALUES ('NULL','playlist_usrs','Playlist Users','Playlist user information','88','no')

function playlist_activate(){
    global $db, $mybb;

    require "../inc/adminfunctions_templates.php";
    $playlist_group = array(
    "gid" => "NULL",
    "name" => "playlist_usrs",
    "title" => "Playlist Users",
    "description" => "Playlist user information",
    "disporder" => "88",
    "isdefault" => "no",

    $db->insert_query(TABLE_PREFIX."settinggroups", $playlist_group);
    $gid = $db->insert_id();

    $playlist_setting_1 = array(
    "sid" => "NULL",
    "name" => "Playlist enable",
    "title" => "Enable",
    "description" => "Would you like to enable Playlist?",
    "optionscode" => "yesno",
    "value" => "yes",
    "disporder" => "1",
    "gid" => intval($gid),

    $db->insert_query(TABLE_PREFIX."settings", $playlist_setting_1);

    $playlist_setting_2 = array(
    "sid" => "NULL",
    "name" => "playlist_setting",
    "title" => "Playlist Setting",
    "description" => "Playlist ID",
    "optionscode" => "text",
    "value" => "68471617",
    "disporder" => "2",
    "gid" => intval($gid),

    $db->insert_query(TABLE_PREFIX."settings", $playlist_setting_2);
[Image: logo153890.png]

You don't need:
require "../inc/adminfunctions_templates.php";
unless you are going to use the find replace templates function
and use MYBB_ROOT."inc/....
To fix your error, remove TABLE_PREFIX.
It's only needed when you're running queries directly, not when using functions like update_query, insert_query, delete_query, etc. These add the prefix since MyBB 1.4 Smile
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.

Users browsing this thread: 1 Guest(s)