There are some search hits for this topic but nothing I have found answers this query.
Client wants Users OnLine displayed.
Following advice in http://www.oziz.co.uk/scripts/php_users.php I have created the MySql database.
When this code is put in a standalone file on the server it works: see http://www.graphicz.eu.com/whoos.php
When it is put into Actinic thus I get errors:
Take a look: http://www.graphicz.eu.com/site1/ scroll right down almost to the bottom
I guess I am missing something glaringly obvious but I would appreciate any advice.
Thank you.
Client wants Users OnLine displayed.
Following advice in http://www.oziz.co.uk/scripts/php_users.php I have created the MySql database.
When this code is put in a standalone file on the server it works: see http://www.graphicz.eu.com/whoos.php
PHP Code:
<?php
//online
$server = "localhost"; // usually localhost
$db_user = "web178-*********";
$db_pass = "*********";
$database = "web178-*********";
$timeoutseconds = 300; // length of gaps in the count
//get the time
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
//connect to database
mysql_connect($server, $db_user, $db_pass);
//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert)) {
print "";
}
//delete values when they leave
$delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout");
if(!($delete)) {
print "";
}
//grab the results
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'");
if(!($result)) {
print "";
}
//number of rows = the number of people online
$user = mysql_num_rows($result);
if(!($user)) {
print("ERROR: " . mysql_error() . "\n");
}
//spit out the results
mysql_close();
print("$user");
?>
A PHP error has been found on the page ('Fatal error: Call to undefined function mysql connect() in main on line 27).
Code:
<actinic:block php="true" > //online $server = "localhost"; // usually localhost $db_user = "web178-*********"; $db_pass = "*********"; $database = "*********"; $timeoutseconds = 300; // length of gaps in the count //get the time $timestamp = time(); $timeout = $timestamp-$timeoutseconds; //connect to database mysql_connect($server, $db_user, $db_pass); //insert the values $insert = mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); if(!($insert)) { print ""; } //delete values when they leave $delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout"); if(!($delete)) { print ""; } //grab the results $result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'"); if(!($result)) { print ""; } //number of rows = the number of people online $user = mysql_num_rows($result); if(!($user)) { print("ERROR: " . mysql_error() . "\n"); } //spit out the results mysql_close(); print("$user"); </actinic:block>
I guess I am missing something glaringly obvious but I would appreciate any advice.
Thank you.
Comment