PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Fri Nov 01, 2002 8:09 am
Code: Select all
<?php
<?php
@mysql_connect('*****','*****','*****') or die ("error:
connecting db host..."); // db host
@mysql_select_db('clancek') or die ("Error: Connecting database...");
//database name
$timeoutseconds = 30; //time limit in secs before the old records are
deleted...
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
$remote = $HTTP_SERVER_VARSї"REMOTE_ADDR"];
$insert = mysql_query("INSERT INTO q_useronline VALUES
'timestamp','$remote')");
if(!($insert)) {
print "Useronline Insert Failed";
}
$delete = mysql_query("DELETE FROM q_useronline WHERE
timestamp<$timeout");
if(!($delete)) {
print "Useronline Delete Failed";
}
$result = mysql_query("SELECT DISTINCT ip FROM q_useronline");
if(!($result)) {
print "Useronline Select Error > ";
}
$user = mysql_num_rows($result);
if($user == 1) {
$online = "<b>Users Online:</b> $user\n";
} else {
$online = "<b>Users Online:</b> $user\n";
}
?>
?>
phpinfo :
http://www.host.sk/phpinfo.html
error: Useronline Insert Failed
works great at localhost with php version 4.0.1, but it does't on the above host
.
thanks for your help.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Nov 01, 2002 8:28 am
try
Code: Select all
$query = "INSERT INTO q_useronline VALUES 'timestamp','$remote')";
$insert = mysql_query($query) or die($query.' :'.mysql_error());
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Fri Nov 01, 2002 8:29 am
Change:
Code: Select all
$insert = mysql_query("INSERT INTO q_useronline VALUES
'timestamp','$remote')");
to
Code: Select all
$sql = "INSERT INTO q_useronline VALUES 'timestamp','$remote')";
$insert = mysql_query($sql);
Instead of:
use
Code: Select all
echo mysql_error().'<p>'.$sql.'</p>';
to get a more useful error message.
Then you should be able to see that you are missing an opening parenthesis after VALUES in the SQL statement.
Mac
superwormy
Forum Commoner
Posts: 67 Joined: Fri Oct 04, 2002 9:25 am
Location: CT
Post
by superwormy » Fri Nov 01, 2002 9:00 am
You have an error in your syntax here:
$insert = mysql_query("INSERT INTO q_useronline VALUES 'timestamp','$remote')");
You're missing the leading ( in the SQL statement.
VALUES ('timestamp','$remote) INSTEAD OF VALUES 'timestamp','$remote')
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Fri Nov 01, 2002 9:17 am
i see
...but it worked on my compter.
thanks