// Get Id, Streamanbieter und StreamId
$sql = mysql_query("SELECT `Id`,`Anbieter`,`StreamId`,`Online` FROM `streams`");
// Aktualisiere streams
while($row = mysql_fetch_object($sql)) {
$id = $row->Id;
$anbieter = $row->Anbieter;
$streamid = $row->StreamId;
$ison = $row->Online;
$set_online = "UPDATE streams Set Online = '1' WHERE Id = $id";
$set_offline = "UPDATE streams Set Online = '0' WHERE Id = $id";
//$set_onlinesince = "UPDATE streams SET Online_since = current_timestamp WHERE Id = $id AND Online_since = '0000-00-00 00:00:00'";
$viewers = get_viewers($streamid, $anbieter);
$update_viewers = "UPDATE streams Set Viewers = $viewers WHERE Id = $id";
$set_zero = "UPDATE streams Set Viewers = 0 WHERE Id = $id";
$set_datezero = "UPDATE streams Set Online_since = '0000-00-00 00:00:00' WHERE Id = $id";
if(get_online($streamid, $anbieter) == true) {
if($ison == 0) {
//mysql_query($set_onlinesince);
}
mysql_query($set_online);
mysql_query($update_viewers);
}
else {
mysql_query($set_offline);
mysql_query($set_zero);
mysql_query($set_datezero);
}
}
Check out the commented lines $set_onlinesince. I had the problem that mysql_query($set_onlinesince) was executed nearly all the time, so I made the IF clause and added an additional statement in the Where clause. It was executed most of times.
After that I made an echo into the IF clause. When I executed the file it didn’t show the echo output but would execute the mysql_query($set_onlinesince). Then I tried to outcomment the line and it still was executed. When I outcomment the variable with the query and it was still executed after page reload. That does freak me out.
I deleted the cache in my browser several times and also tried it in a different browser. There was no effect.
How can this happen???
It could be possible in this scenario that the field is set to
ON UPDATE CURRENT_TIMESTAMP, which would update it automatically with one of the previous queries.