
January 25th, 2013, 10:27 PM
|
|
Contributing User
|
|
Join Date: Dec 2012
Posts: 64
Time spent in forums: 11 h 36 m 11 sec
Reputation Power: 1
|
|
|
"-" Unsupported oprand?
I just wrote the following function to keep track of some daily values, and reset the table to 0 everyday.
PHP Code:
function dailyDate(){
$date = mysql_fetch_assoc(mysql_query("SELECT `date` FROM `daily` WHERE userID = 1"));
$year = date('Y');
$day = date('z');
$currentDate = $year . $day;
if($currentDate - $date['date'] > 0){
mysql_query("UPDATE `daily` SET `date` = '$currentDate' WHERE `userID` = '1'") or die(mysql_error());
mysql_query("UPDATE `daily` SET `views` = 0, `uploads` = 0, `points` = 0") or die(mysql_error());
}
}
For some reason the subtraction of $currentDate - $date produces an error of " Unsupported operand types". I tested doing the calculation outside the if statement, and even tried using settype integer for the date variables just in case something funky was going on there. But for some reason I'm still getting the same error.
Not sure what's causing this, it's just subtraction.
SOLVED: Made the derp mistake of not including the key of the associative array for date.
Last edited by nbasso713 : January 25th, 2013 at 10:36 PM.
|