So I have a class that runs a code on start (function __construct())
This is the function I’m running:
[php]
function checkclear() {
$sql = "select time
from " . $this->conf[‘sql_prefix’] . “maintenance where id
= ‘1’”;
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($res) or die(mysql_error());
if ($row[‘time’] == “”) return ‘purge’;
else {
$diff = $this->date_diff(time(), $row[‘time’]);
//Purge every 24 hours.
if ($diff[‘tseconds’] > 143999) return ‘purge’;
else return ‘no’;
}
$upd = "update " . $this->conf[‘sql_prefix’] . “maintenance SET time
= '” . time() . “’, SET log
= ‘Time updated successfully at " . date(‘m/d/y’) . " " . date(‘hh:mm’) . "’ where id
= ‘1’”;
mysql_query($upd) or die(mysql_error());
print_r($upd);
}
[/php]
I’ve checked the table in mysql, it’s not updating the column I made, it remains blank.
The print_r($upd) returns nothing on the webpage, when it should.
and there are no mysql errors. As far as I know there are no errors within the structure of my code and I’ve written numerous platforms before. What I want from the person reading this is to tell me if A) If I did typo something and I’m not seeing it. Or B) is the server doing something weird and not interpreting my code correctly? Or ignoring it?
What it should be doing is updating the column time
in table (prefix)_maintenance with the current unix timestamp, determine from my time-difference function(Which I know works, and all other values in this code work, because the class is running numerous other things properly) if the difference between the last update to the DB is over 24 hours ago, or if it’s NULL/Blank, update it, whilst returning purge, then another script interprets that to include a file to run a set of commands.