PHP : Date cannot update in correct format

Hi

I inserted date into database in date picker ( i mean calender) format… In MySql its type is Date…
I can insert the date in correct format… But when Iam editind the Date in calender… Its saved as 0000-00-00…
It cannot update in correct format… Pls help me
This is my code… In this C Date and Payement Date…

Please help me for this…

[php]<?php
error_reporting(0);
session_start();
if(!isset($_SESSION[‘admin’])){
echo “”;
}
include("…/includes/dbconnect.php");

$id=$_GET[‘id’];

if(isset($_POST[‘submit’]))
{
$date=$_POST[‘txtDate’];
$advancedpaid=$_POST[‘advancedpaid’];
$paymentdate=$_POST[‘txtDate1’];
$hid=$_POST[‘id’];
$sqlQry =mysql_query(“UPDATE bookdetails SET date = ‘$date’,advancedpaid = ‘$advancedpaid’,paymentdate = ‘$paymentdate’ where id=’$id’”);
{
$m=“

Updated Successfully

”;
}

}
?>

Admin
<?php include("header.php"); ?> <?php include("left.php"); ?>
<?php if(isset($m)) echo $m;?>
<?php $sel_news=mysql_query("select * from bookdetails where id=$id"); $got_news=mysql_fetch_array($sel_news); $rowid=$got_news['id']; $date = $got_news['date']; $advancedpaid = $got_news['advancedpaid']; $paymentdate=$got_news['paymentdate']; ?> <?php include("../includes/dbconnect.php"); $sql=mysql_query("select * from cruize"); ?> <?php include("../includes/dbconnect.php"); $sq=mysql_query("select * from bookdetails"); ?>
 <tr>
  <td colspan="2" align="center">
  <input type="submit" name="submit" id="submit" value="SUBMIT" />      
  <input type="hidden" name="hid" value="<?php echo $rowid; ?>" />
  </td>
 </tr>
 </table>
</form>
[/php]
Booking Form
C Date:
Advanced Paid: Select Yes No

Basically, its reporting an invalid date, you might need to take the user date and change the format to YYYY-MM-DD

Hi

I got correct output…
The code is correct…
In databse i name the field as date… instead of that when i put date1… i got the correct answer…

Thanku… :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service