I have a subscription service and am trying to not allow the buyer to
proceed purchasing another subscription if one of their subscriptions is
over 29 days past due in their payment.  I am trying to query each invoice
and checking to see if it is past due more than 29 days, if it is I want a
message to come up saying that it can not proceed because they account is
not current.  Can you look at the code below and let me know if you see
something wrong.  It is not working for me. Thanks.


------START CODE----------------------------------------------------------

$sql_1 ="SELECT * FROM $table_name
        WHERE buyerid = \"$buyerid\" AND paidinfull is NULL";
$result_1 = @mysql_query($sql_, $connection) or die("Error #" .
mysql_errno() . ": " . mysql_error());

if(mysql_num_rows($result_1) > 0){
         while($row = mysql_fetch_array($result_1)) {

         $duedate1 = $row['duedate'];
           $paiddate1 = $row['paiddate'];
         $paidinfull = $row['paidinfull'];

$duedatestamp = strtotime($duedate1);              // due date unix
timestamp
$difference = time() - $duedatestamp;             // diff in seconds
$differencedays  = $difference / 86400;          // 60 x 60 x 24 hours floor
rounds the days down
$differencedays1 = floor($differencedays);

$paiddatestamp = strtotime($paiddate1);        // paid date unix timestamp
$diffdays = floor(((paiddatestamp - duedatestamp) / 86400));


if (!$paiddate1)
{
        $daysout = $differencedays1;
}
else
{
        $daysout = $diffdays;
}

if ($daysout > 29)
{
echo "You cannot add this product as your account is 30 days past due";
exit;
}

----END CODE--------------------------------------------------------------



--------------------------------------------------------------------------
The content of this email message and any attachments are confidential and
may be legally privileged, intended solely for the addressee.  If you are
not the intended recipient, be advised that any use, dissemination,
distribution, or copying of this e-mail is strictly prohibited.  If you
receive this message in error, please notify the sender immediately by reply
email and destroy the message and its attachments.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to