Jump to content

Help updating date


affordit

Recommended Posts

Im trying to update a registration expiration date the code below is what im trying to use but Ithink I got the syntax wrong at the point where im changing the $end_date to $new_end_date can someone help please

<?php
include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$name,$password);
@mysql_select_db($database) or die( "Unable to select database"); 

//
// CHANGE QUERY TO GRAB THE ID
//
$query = "select id, email, end_date, valid FROM login WHERE `email`= '$email'";
$result=mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result)<1)
{
echo "You must enter your Email address.";
exit();
}
else
{ 
while ($info = mysql_fetch_array($result)) {
$end_date =  $info['end_date'];
$new_end_date = $end_date("Y-m-d",strtotime("+ 5 days"));
}
echo "$new_end_date";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/91421-help-updating-date/
Share on other sites

Change query to:

 

$query = "select id, email, end_date, valid, DATE_ADD(end_date, INTERVAL 5 DAY) AS new_end_date FROM login WHERE `email`= '$email'";

 

Get column with:

 

$new_end_date = $info['new_end_date'];

 

 

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add

 

http://us3.php.net/manual/en/function.date.php

 

http://us3.php.net/manual/en/function.strtotime.php

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/91421-help-updating-date/#findComment-468433
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.