0

Evening all,

I have been creating my own wordpress plugin but I can't get my plugins options page within the admin section to save any of the plugin settings I input to the plugin table I created.

When I input settings in the options page and submit my changes it all looks to be working but when I query the table it is empty and now rows have been inserted.

Any help to fix this issue would be much appreciated.

Thanks in advance,

Xander

My code is listed below.

I have a class which creates a table using this code:

function createGalleryTable() {
        $sql = "CREATE TABLE IF NOT EXISTS `wp_pgp_gallery` (
        `gallery_id` mediumint(6) NOT NULL auto_increment,
        `name` varchar(20) NOT NULL,
        `default_gallery` tinyint(1) NOT NULL default '0',
        `published` tinyint(1) NOT NULL default '0',
        `gallery_desc` varchar(255),
        `display_style` varchar(10) NOT NULL default 'Info',
        PRIMARY KEY  (`gallery_id`),
        KEY `name` (`name`)
        );";
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    }

I have another class which is called by the form submit action which passes a string parameter to be inserted to my table:

function addgallery($pgp_galleryname) {
        global $wpdb;

        $wpdb->insert('wp_pgp_gallery', array(
                            'gallery_id' => NULL,
                            'name' => $pgp_galleryname,
                            'default_gallery' => '0',
                            'published' => '0',
                            'gallery_desc' => NULL,
                            'display_style' => 'Info'
                        )
                    );
        $lastid = $wpdb->insert_id;
    }

1 Answer 1

0

Do no pass gallery_id on insert as it is an auto increment field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.