Reputation: 821
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']);
$insertEvent->execute();
echo'Sucess';
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">
<label>
<span>Title:</span>
<input type="text" name="title" value="<?php if(isset($_POST['title'])) echo $f['title']; ?>" />
</label>
<label>
<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']; ?>" />
</label>
<label>
<span>End Date:</span>
<input type="text" class="datepicker" name="date_end" value="<?php if(isset($_POST['date_end'])) echo $f['date_end']; ?>" />
</label>
<label>
<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>
</select>
</label>
<input type="submit" value="Insert" name="sendForm" />
</form>
Upvotes: 1
Views: 1530
Reputation: 74217
Its not working also with datetime, and the datepicker format is like "04/30/2014" and datetime is "0000-00-00". So maybe this is reallty the problem!
You need to switch it around so that's it's Y-M-D instead of M-D-Y
Notice the 4x 0000
's then the other 2x 00
's? Your date is the opposite.
Upvotes: 1