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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.