Online?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Online?

    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.
    Code:
    I included this in the required pages...
    <?php
    $tyd = 120;
    $dabar = time();
    $timeout = $tyd1 - $tyd;
    $name = $_GET[&#39;name&#39;];
    mysql_query("DELETE FROM online WHERE name<$timeout");
    
    mysql_query("UPDATE online SET time=&#39;120&#39; WHERE site=&#39;".$site."&#39; AND name=&#39;".$name."&#39;");
    
    ?>
    Online SQL
    Code:
    CREATE TABLE `online` (
      `id` int(4) NOT NULL auto_increment,
      `site` varchar(15) NOT NULL default &#39;&#39;,
      `name` varchar(15) NOT NULL default &#39;&#39;,
      `time` int(15) NOT NULL default &#39;0&#39;,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `name` (`name`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    On my login page.
    Code:
    mysql_query("INSERT INTO online WHERE site=&#39;".$site."&#39;" AND name=&#39;".$name."&#39; AND time=&#39;120&#39;);
    Please help here, , , i think i&#39;m going totaly wrong

    Click here!!!

    #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...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      I&#39;ll use whatever that works lol

      Click here!!!

      Comment


        #4
        If you only want to delete this code will work

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

        Comment


          #5
          Thank you, I&#39;ll try it quick.

          Click here!!!

          Comment


            #6
            Code:
            $offline = 120;
            
            $name = $_GET[&#39;name&#39;];
            
            $deloff = "DELETE FROM online WHERE time <&#39;".intval(time()-$offline)."&#39;";
            $dodel = mysql_query($deloff) or die("Could not delete online entry!");
            
            $insert_data="UPDATE online SET time=&#39;".time()."&#39;WHERE site=&#39;".$site."&#39; AND name=&#39;".$name."&#39;";
            $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=&#39;".$site."&#39;" AND name=&#39;".$name."&#39; AND time=&#39;120&#39;);[/b]

            Comment


              #7
              Thank you

              Click here!!!

              Comment


                #8
                mmm strugling a bit here.

                Click here!!!

                Comment


                  #9
                  Ok wait, i got a better code for add to online, but it doesn&#39;t want to add you to the online list.

                  Code:
                  mysql_query("INSERT INTO `online` (
                  `id` ,
                  `site` ,
                  `name` ,
                  `time` 
                  )
                  VALUES (
                  &#39;&#39;, &#39;".$site."&#39;, &#39;".$name."&#39;, &#39;120&#39;
                  );");

                  Click here!!!

                  Comment


                    #10
                    mysql_query("INSERT INTO `online` (
                    `id` ,
                    `site` ,
                    `name` ,
                    `time`
                    )
                    VALUES (
                    &#39;&#39;, &#39;".$site."&#39;, &#39;".$name."&#39;, &#39;120&#39;
                    );");[/b]

                    Code:
                    $insert_data="INSERT INTO online SET site=&#39;".$site."&#39;" AND name=&#39;".$name."&#39; AND time=&#39;".time()."&#39;";
                    $do = mysql_query($insert_data) or die("Could not insert online!");

                    Comment


                      #11
                      dont forget

                      Code:
                      $name = mysql_real_escape_string($_GET[&#39;name&#39;]);
                      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

                      Comment


                        #12
                        Code:
                        $insert_data="INSERT INTO online SET site=&#39;".$site."&#39;" AND name=&#39;".$name."&#39; AND time=&#39;".time()."&#39;";
                        $do = mysql_query($insert_data) or die("Could not insert online!");
                        1st time I saw AND clause in INSERT sql command

                        Comment

                        Working...
                        X