How do you calculate today's date - minus a db Date Entry?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you calculate today's date - minus a db Date Entry?

Post by simonmlewis »

the error ONLY occurs when this is in place

Code: Select all

$result = ($thedate - $addedDays);
Without that, and with the other stuff, even the IF statement on the $result, it won't error at all.

This makes it error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: How do you calculate today's date - minus a db Date Entry?

Post by Mirge »

In the code you posted earlier, it shows as: $resulta = ($thedate - $datesubmitted);

If you're using $result = ($thedate - $datesubmitted)... make sure you're not still using $result in a mysql_fetch_* function, as.. as the error says, is not a valid mysql result.....it's just a string, number, whatever now. I'd recommend not mixing up your variables like that... change $result to something else for your ($thedate - $datesubmitted) value.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you calculate today's date - minus a db Date Entry?

Post by simonmlewis »

Yes - about 30 seconds ago it just clicked here too - $result - is the entire cause to the problem.
I changed it and it works.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: How do you calculate today's date - minus a db Date Entry?

Post by Mirge »

simonmlewis wrote:Yes - about 30 seconds ago it just clicked here too - $result - is the entire cause to the problem.
I changed it and it works.
lol... don't ya hate that. :banghead:

Glad ya got it resolved though.
Post Reply