Hello,
I’m working on a classifieds page for a client and they want a specific custom end date for the ads. Specifically, they want all ads to be disabled every two weeks on tuesday at 12pm. I’ve made a form and a php file to post the data into the db. So far everything works and no errors but I’m not able to get my enddate table to post the correct date. I tried to echo the code [php]$startdate = strtotime(“Tuesday”);
$enddate = strtotime("+2 weeks", $startdate);[/php] and it worked fine. However, the dates in my db are not correct and show as: “0000-00-00 00:00:00”
here is my code with the sensitive info scrubbed:
[php]
//for testing & debugging purposes
//echo $_POST[‘name’];
//echo $_POST[‘email’];
//echo $_POST[‘phone’];
//echo $_POST[‘title’];
//echo $_POST[‘category’];
//echo $_POST[‘price’];
//echo $_POST[‘details’];’
//print_r($_POST);
$startdate = strtotime(“Tuesday”);
$enddate = strtotime("+2 weeks", $startdate);
$query = “INSERT INTO wp_awpcp_ads
(
ad_contact_name,
ad_contact_email,
ad_contact_phone,
ad_title,
ad_category_id,
ad_item_price,
ad_details,
disabled,
disabled_date,
ad_postdate,
ad_startdate,
ad_last_updated,
ad_enddate
)
VALUES
(
‘$_POST[name]’,
‘$_POST[email]’,
‘$_POST[phone]’,
‘$_POST[title]’,
‘$_POST[category]’,
‘$_POST[price]’,
‘$_POST[details]’,
1,
now(),
now(),
now(),
now(),
$enddate
)”;
if (mysql_query($query))
{
echo “New record created successfully”;
//header(‘Location: index.php’);
}
else {die(“Unable to post data”);}
?>
thanks in advance for any assistance