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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121305
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121309
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121331
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121346
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121661
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121676
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
https://forums.phpfreaks.com/topic/26514-datetime-stuff/#findComment-121678
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.