• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[MySQL]Users Online Plugin Help

Grandmaster

Electronica Addict
Political User
#1
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
 

Khayman

I'm sorry Hal...
Political User
#2
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
 

Grandmaster

Electronica Addict
Political User
#3
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:
 

albybum

Penguin Rancher
#4
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.
 

Khayman

I'm sorry Hal...
Political User
#5
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
 

Grandmaster

Electronica Addict
Political User
#6
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
 

X-Istence

*
Political User
#8
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.
 

Grandmaster

Electronica Addict
Political User
#10
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
 
#11
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.
 

X-Istence

*
Political User
#14
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?
 
#16
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.
 

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,014
Latest member
sanoravies