2014-04-29 23:08


  • php
  • mysql
  • datepicker
  • sql

Im doing an insert with PDO that it seems correct for me, and the insert is working.

But the date_begin and date_end info is not inserting, my table receivs in this fields the value of :"0000-00-00 00:00:00.000000".

Im using datepicker to choose date.

Do you see what Can be wrong? I dont receive any error or notice!

My insert with pdo:

$insertEvent = $pdo->prepare("INSERT INTO events (title, level, date_begin, date_end) VALUES (:title, :level, :date_begin, :date_end)");  
$insertEvent->bindValue(':title', $f['tile']);
$insertEvent->bindValue(':level', $f['level']);
$insertEvent->bindValue(':date_begin', $f['date_begin']);
$insertEvent->bindValue(':date_end', $f['date_end']);

If I print this variables, they have the right data that I choose in date picker:

echo $f['date_begin'];
echo $f['date_end'];

My form:

<form action="" method="post" enctype="multipart/form-data">

            <input type="text"  name="title" value="<?php if(isset($_POST['title'])) echo $f['title']; ?>" />

            <span class="data">Begin Date:</span>
            <input type="text" class="datepicker" name="date_begin" value="<?php if(isset($_POST['date_begin'])) echo $f['date_begin']; ?>" />

            <span>End Date:</span>
            <input type="text" class="datepicker" name="date_end" value="<?php if(isset($_POST['date_end'])) echo $f['date_end']; ?>" />

           <span>Select the level:</span>
            <select name="level">
            <option value="">Select the user level;</option>
            <option value="1">1</option>
            <option value="2">2</option>        

        <input type="submit" value="Insert" name="sendForm" />

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享