[MySQL]Users Online Plugin Help

Discussion in 'Web Design & Coding' started by Grandmaster, Sep 5, 2004.

  1. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    I'm trying to setup a little plugin for Wordpress that will shows how many people are online on my site. Well I get a little error which says "Database error: [Table 'fganai_blog.wp_useronline' doesn't exist]". That would be the table in the database that this plugin would like to use. However, obviously it does not exist.

    I have phpmyadmin that I can use to create a table, but I have no idea what different variables are required to create the thing. I probably have not given enough info, because I don't know what kind of info you would need. So feel free ask for more. Thanks.

    The page is here: http://ofg.ganai.com/wp-useronline.php
     
  2. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    You need the file "wp-useronline-install.php" which was in the zip, this will create the table you need

    the readme says put it in the "wp-admin" folder, whether you have I do not know, or whether it works.
    If it comes to it you could always just run the sql statement which is in the file in phpmyadmin
     
  3. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Yep, I followed all the instructions from the read-me. That's why I posted here :)

    So I'm guessing somehow it isn't getting permission to create the table, even though the database is allowed...

    Here is the code from the wp-useronline-install.php file.

    Code:
    <?php
    // Require WordPress Config
    require_once('../wp-config.php');
    
    // Create Useronline Table
    $sql[] = " CREATE TABLE $tableuseronline (" .
      " `timestamp` int(15) NOT NULL default '0'," .
      " `username` varchar(50) NOT NULL default ''," .
      " `ip` varchar(40) NOT NULL default ''," .
      " `location` varchar(255) NOT NULL default ''," .
      " `url` varchar(255) NOT NULL default ''," .
      " PRIMARY KEY  (`timestamp`)," .
      " KEY `username` (`username`)," .
      " KEY `ip` (`ip`)," .
      " KEY `file` (`location`)" .
      ")";
    
    foreach($sql as $query) {
    	$wpdb->query($query);
    }
    ?>
    
    So want to help me decipher that sql statement? :eek:
     
  4. albybum

    albybum Penguin Rancher

    Messages:
    280
    Location:
    Elizabethton, TN
    I assume you are running Apache on some Unix/Linux variant.

    Make sure this wp-useronline-install.php has full permissions. CHMOD it for execute and try to run it. Just make sure to set it back after you run it.

    Also, double check in the config file and make sure it is trying to use the correct username/password/database for the action.
     
  5. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    You should be able to run the SQL in phpmyadmin

    Code:
    CREATE TABLE wp_useronline ('timestamp' int(15) NOT NULL default '0', 
       'username' varchar(50) NOT NULL default '',
       'ip' varchar(40) NOT NULL default '',
       'location' varchar(255) NOT NULL default '',
       'url' varchar(255) NOT NULL default '',
       PRIMARY KEY  ('timestamp'),
       KEY 'username' ('username'),
       KEY 'ip' ('ip'),
       KEY 'file' ('location'))
    you should be able to just copy and paste the above
     
  6. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Alright, table has been created... I get this error now:

    I get that from phpmyadmin when I ran the stuff in your post Khayman.

    I also get an error from wp-useronline.php:

     
  7. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Looks like some spaces (" ") were missing while copying -> pasting the SQL query. The quesry itself is fine :huh
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Code:
    CREATE TABLE wp_useronline (
    'time-stamp' int(15) NOT NULL default '0', 
       'username' varchar(50) NOT NULL default '',
       'ip' varchar(40) NOT NULL default '',
       'location' varchar(255) NOT NULL default '',
       'url' varchar(255) NOT NULL default '',
       PRIMARY KEY  ('time-stamp'),
       KEY 'username' ('username'),
       KEY 'ip' ('ip'),
       KEY 'file' ('location')
    );
    This should work: timestamp is a reserved keyword in MySQL.
     
  9. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    Then you have to go through the rest of the code and change any reference to that column
     
  10. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Still get the error.

     
  11. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    this
    should be
    ^^ Note the added space between 'time-stamp' and int AND 'username' and varc(har). Something is a bit messed up in php (and or phpMyAdmin), me thinks.
     
  12. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    try this
    Simple query, if it goes wrong, then beat it up :) :p
     
  13. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Looks like I'll have to pull out my baseball bat :p
     
  14. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Code:
    CREATE TABLE `wp_useronline` (
    `time-stamp` INT( 15 ) DEFAULT '0' NOT NULL ,
    `username` VARCHAR( 50 ) NOT NULL ,
    `ip` VARCHAR( 40 ) NOT NULL ,
    `location` VARCHAR( 255 ) NOT NULL ,
    `url` VARCHAR( 255 ) NOT NULL ,
    PRIMARY KEY ( `time-stamp` ),
    KEY 'username' ('username'),
    KEY 'ip' ('ip'), 
    KEY 'file' ('location')
    );
    
    This works. Are you sure you are not trying to execute pgsql code on MySQL?
     
  15. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Nope, I'm trying to run MySQL queries. And it still won't work. Bah!
     
  16. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Huh? I just tried executing the SQL on my MySQL server and it resulted in an error:
    :confused: Looks like the wrong syntax for KEY, could that be it?

    Anyway, I am still thinking something is wrong in your phpMyAdmin, somehow it removes the space between the column name and the column markup.
     
  17. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    hmm, this is frustrating. I think I'll open a ticket with my host later today.