Online?

Started on the old forum in June 2008 · view the original in the archive · old links redirect here

11 replies · 1,096 views · started 18 years ago · 1 min read

5 participants
SpiderWap Lead · 622 posts #1

Hi there

I'm not really to clever with this, havnt really used it alot.

Can someone perhaps help me out here? I don't think what i done here is right, example, i want to delete users from online list on my new script if theyr idle time is to long.

I included this in the required pages...
<?php
$tyd = 120;
$dabar = time();
$timeout = $tyd1 - $tyd;
$name = $_GET['name'];
mysql_query("DELETE FROM online WHERE name<$timeout");

mysql_query("UPDATE online SET time='120' WHERE site='".$site."' AND name='".$name."'");

?>

Online SQL

CREATE TABLE `online` (
  `id` int(4) NOT NULL auto_increment,
  `site` varchar(15) NOT NULL default '',
  `name` varchar(15) NOT NULL default '',
  `time` int(15) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

On my login page.

mysql_query("INSERT INTO online WHERE site='".$site."'" AND name='".$name."' AND time='120');

Please help here, , , i think i'm going totaly wrong

subzero Super moderator Fellow · 3,954 posts #2

why use all online ? dont you wont to use id ?

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Guest #4

If you only want to delete this code will work

<?php
$dabar = time() - 120;
mysql_query("DELETE FROM online WHERE time<$dabar");

?>
Anshul Senior · 296 posts #6
$offline = 120;

$name = $_GET['name'];

$deloff = "DELETE FROM online WHERE time <'".intval(time()-$offline)."'";
$dodel = mysql_query($deloff) or die("Could not delete online entry!");

$insert_data="UPDATE online SET time='".time()."'WHERE site='".$site."' AND name='".$name."'";
$do = mysql_query($insert_data) or die("Could not update user data!");

try this

On my login page. CODE mysql_query("INSERT INTO online WHERE site='".$site."'" AND name='".$name."' AND time='120');

SpiderWap Lead · 622 posts #9

Ok wait, i got a better code for add to online, but it doesn't want to add you to the online list.

mysql_query("INSERT INTO `online` (
`id` ,
`site` ,
`name` ,
`time` 
)
VALUES (
'', '".$site."', '".$name."', '120'
);");
Anshul Senior · 296 posts #10

mysql_query("INSERT INTO online ( id , site , name , time ) VALUES ( '', '".$site."', '".$name."', '120' );");

$insert_data="INSERT INTO online SET site='".$site."'" AND name='".$name."' AND time='".time()."'";
$do = mysql_query($insert_data) or die("Could not insert online!");
djlee Developer · 224 posts #11

dont forget

$name = mysql_real_escape_string($_GET['name']);

unless ofc ourse you want someone coming along and injecting some nice stuff into your database ... this is why i dont use SET on an INSERT INTO statement.. its much easier to exploit SET than it is to exploit table() VALUE() constructed queries

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close