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
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 9:05 am
Hello,
I am storing the value of mktime in the endingdate column which is a bigint(20) unsigned field. I can get the value out just fine, but when I do math on it it overwrites. Here's what I'm doing: (using Database.class.php)
Code: Select all
$sql = "SELECT endingdate FROM mytable WHERE id='".$id."'";
$row = $db->query_first($sql);
if ($row['endingdate'] != "") {
$days = 86400 * $days;
$endingdate += $days;
$daysinfo['endingdate'] = $endingdate;
$db->query_update("mytable", $daysinfo, "id='".$id."'");
} This is driving me nuts
I cannot troubleshoot this the normal way because this is in my Paypal ipn return script. So I cannot echo anything to the screen. Any ideas?
Thanks!
php_east
Forum Contributor
Posts: 453 Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.
Post
by php_east » Sat Mar 21, 2009 12:02 pm
is it right to have $daysinfo array in the update field, or should it be $daysinfo['endingdate'] ?
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 12:08 pm
php_east wrote: is it right to have $daysinfo array in the update field, or should it be $daysinfo['endingdate'] ?
Yes, from the documentation that field takes an "assoc array with data".
Thanks though
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 9:27 pm
I have simplified the problem even more. Someone has to be able to tell me why this is happening.
Code: Select all
$sql = "SELECT endingdate FROM mytable WHERE id='".$id."'";
$row = $db->query_first($sql);
if ($row['endingdate'] != "") {
echo "endingdate1: ".$row['endingdate']."<br />";
$endingdate = $endingdate + 1;
echo "endingdate2: ".$endingdate."<br />";
}
Here are the results:
Code: Select all
endingdate1: 1237694670
endingdate2: 1
Why is endingdate2 echoing 1 when it should be 1237694671?
Thanks!
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 9:30 pm
Aaaaaaaaaaahhhhhhhhhhh, I GOT IT!!!!
Never mind
php_east
Forum Contributor
Posts: 453 Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.
Post
by php_east » Sat Mar 21, 2009 10:11 pm
string+numeric maybe.
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 10:22 pm
Nope. The answer is just staring you in the face. Don't feel bad, it took me about 4 hours to figure it out.
It is easier than you think.
php_east
Forum Contributor
Posts: 453 Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.
Post
by php_east » Sat Mar 21, 2009 10:32 pm
ah yes, if it was a snake you would have been bitten.
$endingdate = $endingdate + 1;
$endingdate=null
i don't feel bad, just curious. things like this catches us all the time, even the seasoned ones.
vbmark
Forum Newbie
Posts: 19 Joined: Sun Feb 15, 2009 8:53 pm
Post
by vbmark » Sat Mar 21, 2009 10:36 pm
Yup. I just can't believe how much time I wasted on this.
I was googling eveything I could find about mktime.
Oh well. I can get on with my life now.