Forum Moderators: coopster
<?
$offset_ldg_cron_script=7; /* dued to server timezone offset*/
$seconds_of_tolerance=600; /*10 minutes*/
$date_10_minutes_ago=date('Y-m-d', time()-$seconds_of_tolerance + $offset_ldg_cron_script * 3600);
$time_10_minutes_ago=date('H:i:s', time()-$seconds_of_tolerance + $offset_ldg_cron_script * 3600);
$query_var_appoggio=" SELECT DISTINCT id_content,value
FROM my_table
WHERE content_insert_date <='".$date_10_minutes_ago."'
AND content_insert_time <='".$time_10_minutes_ago."'
ORDER BY content_insert_date DESC,content_insert_time
DESC LIMIT 30";
$query_result = mysql_query($query_var_appoggio);
>
Some additional info:
into table, the fields content_insert_date and content_insert_time
are defined as: date and time fields, and in the same format of
compared values ( eg; '2008-06-25' , '14:26:23')
If I remove third and forth line in the query
WHERE content_insert_date <='".$date_10_minutes_ago."'
AND content_insert_time <='".$time_10_minutes_ago."'
the query goes well but so I can't filter contents avoiding to insert too recent ones.
Is there somebody that can help me?
Thanks in advance!
lore
(sorry for my english)
I don't see any problems with your code, but I know if you change methods it would be much easier (You would not have to keep track of both data and time, only timestamp). The problem with the query may be the Data and Time columns; they take data in a specific way, and I'm not sure what format it should be using.
If you switch to the timestamp function, you need only search for "WHERE content_insert_timestamp <= " . (time()-600)
If you cannot do that change, check the format of the date and time columns. I think they use the same format, and PHP variables do not match the format, I think.
Thanks in advance.
lore
(i think that I have to search the solution in MySQL website...
...there are a lot of mistakes in MySQL engine (like in every kind of software, of course...)
and the list of bugs is always very long...)
Sometimes the problem is caused by "lower-layer" bugs.
lore
$query_var_appoggio=" SELECT DISTINCT id_content,value
FROM my_table
WHERE content_insert_date <= DATE_SUB(NOW(), INTERVAL 10 MINUTE)
AND content_insert_time <= DATE_SUB(NOW(), INTERVAL 10 MINUTES)
ORDER BY content_insert_date DESC,content_insert_time
DESC LIMIT 30";
lore