how to PDO expiry date

1Tsme1941

Member
Hi, I'm trying to confirm an expiraton date from a database table. I'm
finally trying PDO. I get:
Parse error: syntax error, unexpected 'y' (T_STRING) on line 10
--------------------------------------------------
The code:
<?php
error_reporting(E_ALL); /* show all errors - server configured at 6135,
increases to 6143 (PHP version 5.2.11) -- comment this line out when LIVE
ini_set('display_errors','On'); // turn on error display -- comment this line out when LIVE */

// set expiration date in YYYY-MM-DD format
$contract_expiration = '2021-08-25;

// computes days remaining -- (60s*60m*24h) represents 1 day
$days_remaining = round( (( strtotime($contract_expiration) - strtotime(date('y-m-d')) ) / (60*60*24)) ); // line 10
if ($days_remaining < 31)
{
// formats expiration date as M/D/YY
$contract_expiration_formatted = date('n/j/y',strtotime($contract_expiration));
// alert message for contracts expiring today
if ($days_remaining == 7) $GLOBALS['contract_status'] = 'expires in a week!';
// alert message for contracts expiring tomorrow
elseif ($days_remaining == 1) $GLOBALS['contract_status'] = 'expires tomorrow!';
// alert message for contracts expiring in 2-30 days
else $GLOBALS['contract_status'] = 'expires in '.$days_remaining.' days - on '.$contract_expiration_
formatted;
//}
// contract period is beyond 30 days
else $GLOBALS['contract_status'] = 'is current';
// if today's date is greater than your expiration date
if (date('Y-m-d') > $contract_expiration)

{
header("location:pass-chek-php");
// echo "We're sorry but your contract has expired...";
// a status alert message or u can populate with web document
exit;
// kills script & prevents parser from rendering your web app below
//}

else { } ?>
 

Cromewell

Administrator
Staff member
$contract_expiration = '2021-08-25;
In this case, your error is actually here. The hint that php gives you that tells you the error is actually earlier and it is a missing closing quote somewhere is that it found an unexpected T_STRING at the very start of what looks like a quoted string.
 
Top