• I have tried everything I can possibly think of to get ANYTHING under wp_dlayouts to display, and have been unsuccessful. I only get a blank page for the plugin. I am asking for help, as I’ve spent the past 6+ hours trying to get it. I want to be able to list everything in the wp_dlayouts, like the thumbnail, name, etc. Which is listed here:

    $sql = "CREATE TABLE IF NOT EXISTS$table_name` (
    id int(5) NOT NULL AUTO_INCREMENT,
    name varchar(255) NOT NULL DEFAULT ”,
    artist varchar(200) NOT NULL DEFAULT ”,
    artisturl varchar(255) NOT NULL DEFAULT ”,
    series varchar(255) NOT NULL DEFAULT ”,
    category varchar(255) NOT NULL DEFAULT ”,
    previewimage varchar(255) NOT NULL DEFAULT ”,
    download varchar(255) NOT NULL DEFAULT ”,
    viewhtml varchar(255) NOT NULL DEFAULT ”,
    date date NOT NULL DEFAULT ‘0000-00-00’,
    previews int(5) NOT NULL DEFAULT ‘0’,
    downloads int(5) NOT NULL DEFAULT ‘0’,
    rating varchar(10) NOT NULL DEFAULT ‘0’,
    votes int(10) NOT NULL DEFAULT ‘0’,
    filesize varchar(10) NOT NULL DEFAULT ‘0’,
    user_uploaded varchar(255) NOT NULL DEFAULT ‘admin’,
    keywords varchar(255) NOT NULL DEFAULT ”,
    PRIMARY KEY (id)`

    Like i said, i can’t get anything to display, and I know the coding is pretty messy, but I’m trying to convert a php/msyql script over to a wordpress plugin because apparently no one has what I want, EXCEPT this script. And also let me know if you see anything else that is incredibly incorrect.

    <?php
    /**
     * Plugin Name: Layout Database
     * Plugin URI: http://hateyourway.org
     * Description: A brief description of the Plugin.
     * Version: 2.0
     * Author: Daniel Hatcher
     * Author URI: http://residentfantasy.com
     * License: A "Slug" license name e.g. GPL2
     */
    
    function requires_wordpress_version() {
    	global $wp_version;
    	$plugin = plugin_basename( __FILE__ );
    	$plugin_data = get_plugin_data( __FILE__, false );
    
    	if ( version_compare($wp_version, "3.3", "<" ) ) {
    		if( is_plugin_active($plugin) ) {
    			deactivate_plugins( $plugin );
    			wp_die( "'".$plugin_data['Name']."' requires WordPress 3.3 or higher, and has been deactivated! Please upgrade WordPress and try again.<br /><br />Back to <a href='".admin_url()."'>WordPress admin</a>." );
    		}
    	}
    }
    add_action( 'admin_init', 'requires_wordpress_version' );
    
    register_activation_hook(__FILE__,'table_add');
    function table_add()
    {
        global $wpdb;
    
        $table_name = $wpdb->prefix . 'dlayouts';
    	 $table_name1 = $wpdb->prefix . 'dseries';
    	  $table_name2 = $wpdb->prefix . 'dusers';
    
        $sql = "CREATE TABLE IF NOT EXISTS <code>$table_name</code> (
      <code>id</code> int(5) NOT NULL AUTO_INCREMENT,
      <code>name</code> varchar(255) NOT NULL DEFAULT '',
      <code>artist</code> varchar(200) NOT NULL DEFAULT '',
      <code>artisturl</code> varchar(255) NOT NULL DEFAULT '',
      <code>series</code> varchar(255) NOT NULL DEFAULT '',
      <code>category</code> varchar(255) NOT NULL DEFAULT '',
      <code>previewimage</code> varchar(255) NOT NULL DEFAULT '',
      <code>download</code> varchar(255) NOT NULL DEFAULT '',
      <code>viewhtml</code> varchar(255) NOT NULL DEFAULT '',
      <code>date</code> date NOT NULL DEFAULT '0000-00-00',
      <code>previews</code> int(5) NOT NULL DEFAULT '0',
      <code>downloads</code> int(5) NOT NULL DEFAULT '0',
      <code>rating</code> varchar(10) NOT NULL DEFAULT '0',
      <code>votes</code> int(10) NOT NULL DEFAULT '0',
      <code>filesize</code> varchar(10) NOT NULL DEFAULT '0',
      <code>user_uploaded</code> varchar(255) NOT NULL DEFAULT 'admin',
      <code>keywords</code> varchar(255) NOT NULL DEFAULT '',
      PRIMARY KEY (<code>id</code>)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ";
    
        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        dbDelta( $sql );
    
       $sql = "CREATE TABLE IF NOT EXISTS <code>$table_name1</code> (
      <code>id</code> int(5) NOT NULL AUTO_INCREMENT,
      <code>name</code> varchar(255) NOT NULL,
      PRIMARY KEY (<code>id</code>)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ";
    
        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        dbDelta( $sql );
    
    	   $sql = "CREATE TABLE IF NOT EXISTS <code>$table_name2</code> (
      <code>id</code> int(5) NOT NULL AUTO_INCREMENT,
      <code>name</code> varchar(255) NOT NULL,
      <code>level</code> varchar(255) NOT NULL DEFAULT '1',
      PRIMARY KEY (<code>id</code>)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ";
    
        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        dbDelta( $sql );
    
    }
    
    //*****************************************************************************************
    
    /**
      *Function to Update Db Version in WordPress Database
      *Created on 17 aug 2012
      *By Neeraj Sukheja
    */
    function myplugin_update_db_check() {
        global $table_db_version;
        if (get_site_option('table_db_version') != $table_db_version) {
            table_add();
        }
    }
    add_action('plugins_loaded', 'myplugin_update_db_check');
    
    register_uninstall_hook(__FILE__, 'table_delete');
    add_action('admin_init', 'design_init' );
    
    add_filter( 'plugin_action_links', 'design_plugin_action_links', 10, 2 );
    
    add_action( 'admin_menu', 'register_my_custom_menu_page' );
    
    function register_my_custom_menu_page(){
        add_menu_page( 'custom menu title', 'Layout Designs', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ), 6 ); 
    
    $thepost = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->dlayouts WHERE ID = 1" ) );
    echo $thepost->dlayouts_name;
    $wpdb->show_errors();
    }
    
    ?>
  • The topic ‘Can't get custom tables to display’ is closed to new replies.