Jump to content

datetime stuff


almightyegg

Recommended Posts

hmm...
[code=php:0]
$sql2 = mysql_query("SELECT * FROM users WHERE last_login > $time INTERVAL 10 MINUTES");
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($sql2);
[/code]
are you sure thats a real code :P

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 16

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 17
Link to comment
Share on other sites

[quote author=almightyegg link=topic=114205.msg464618#msg464618 date=1162944744]
hmm...
[code=php:0]
$sql2 = mysql_query("SELECT * FROM users WHERE last_login > $time INTERVAL 10 MINUTES");
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($sql2);
[/code]
are you sure thats a real code :P

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 16

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 17

[/quote]

you put...
[code]
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($sql2);
[/code]

its
[code]
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($mem2);
[/code]
your using the query.. not the sql
Link to comment
Share on other sites

[code]$sql2 = "SELECT * FROM users WHERE last_login > ".gmdate("Y-m-d H:i:s")." - INTERVAL 10 MINUTES";[/code]

how about that?

i remember looking up the same thing ages ago myself (i use php's time() now.. easy to manipulte)
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
more info on date and interval
Link to comment
Share on other sites

[quote author=stewart715 link=topic=114205.msg464642#msg464642 date=1162946835]
[code]
<?php
//date("i")-10 means 10 minutes ago
$time = mktime(0, 0, 0, 0, 0, 0, date("m"), date("d"),  date("Y"), date("H"), date("i")-10, date("s"));

$sql2 = mysql_query("SELECT * FROM users WHERE last_login < $time");
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($mem2);
?>[/code]

maybe?
[/quote]
Link to comment
Share on other sites

nah, that got multipul errors... i am thinking somethingmlike:
[code=php:0]
$time = gmdate("Y-m-d H:i:s",strtotime(-0010));


$sql2 = mysql_query("SELECT * FROM users WHERE last_login > $time");
$mem2 = mysql_fetch_array($sql2);
$numr = mysql_num_rows($mem2);
[/code]
the -0010 was me trying to do -10 minutes :( but it takes off 10 hours instead
Link to comment
Share on other sites

i missed something out  :-\ oops :P that sorts that problem....

but i get some errors counting rows...
[quote]
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 17

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/index.php on line 18

[/quote]

[code=php:0]
$time = gmdate("Y-m-d H:i:s",time()-60*10);


$sql2 = mysql_query("SELECT * FROM users WHERE last_login > $time");
$mem2 = mysql_fetch_array($sql2); //line17
$numr = mysql_num_rows($mem2); //line18
[/code]
Link to comment
Share on other sites

I suppose you connected to the DB, right?

First, try chaning the line in the following way:
$sql2 = mysql_query("SELECT * FROM users WHERE last_login > '$time'");

If that doesnt work, let's see if there's any error:
$sql2 = mysql_query("SELECT * FROM users WHERE last_login > '$time'") or die(mysql_error());

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.