[MySQL]Users Online Plugin Help

Grandmaster

Electronica Addict
Political Access
Joined
3 Feb 2002
Messages
10,574
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
 
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
 
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:
 
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.
 
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
 
Alright, table has been created... I get this error now:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''timestamp'int( 15 ) NOT NULL default '0',
'username'varch
I get that from phpmyadmin when I ran the stuff in your post Khayman.

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

Warning: Invalid argument supplied for foreach() in /home/fganai/public_html/ofg/wp-useronline.php on line 48
 
Looks like some spaces (" ") were missing while copying -> pasting the SQL query. The quesry itself is fine :huh
 
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.
 
Then you have to go through the rest of the code and change any reference to that column
 
Still get the error.

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''time-stamp'int( 15 ) NOT NULL default '0',
'username'varc
 
this
''time-stamp'int( 15 ) NOT NULL default '0',
'username'varc

should be
''time-stamp' int( 15 ) NOT NULL default '0',
'username' varc
^^ 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.
 
Looks like I'll have to pull out my baseball bat :p
 
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?
 
Nope, I'm trying to run MySQL queries. And it still won't work. Bah!
 
Huh? I just tried executing the SQL on my MySQL server and it resulted in an error:
mysql> 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')
-> );
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresp
onds to your MySQL server version for the right syntax to use near ''username' (
'username'),
KEY 'ip' ('ip'),
KEY 'file' ('locatio
: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.
 
hmm, this is frustrating. I think I'll open a ticket with my host later today.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back