I'm trying to add a date field to a from and save to PHP/MySQL database. I'm using phpMyAdmin and have set the 'edate' field to 'DATE' type.
My PHP file to save the data is:
$statement = $db->stmt_init();
date_default_timezone_set('UTC');
$edate = $_POST['edate'];
$timestamp = date('dd-mm-yyyy', strtotime($edate));
//database insert statement
$statement->prepare("INSERT INTO events (lat, lon, name, description, category, edate) VALUES (?, ?, ?, ?, ?, '$timestamp')");
//grab values from the url and add to database
$statement->bind_param("ddsssi", $_POST['lat'], $_POST['lon'], $_POST['name'], $_POST['description'], $_POST['category'], $_POST['edate']);
$status = $statement->execute();
But when i run the PHP file in the browser. it gives teh following error:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in /Users/Stephen/Sites/tidy_map/adddata.php on line 18
with line 18 being:
$statement->bind_param("ddsssi", $_POST['lat'], $_POST['lon'], $_POST['name'], $_POST['description'], $_POST['category'], $_POST['edate']);
The Form is part of a Google Map using Google Maps API V3 - when a new marker is added to the map, it opens an InfoWindow which displays the form with some Javascript:
// Add Foem to New Info Window
google.maps.event.addListener(drawingManager, 'overlaycomplete', function (point)
{
//"clone" the event-form to put in the infowindow
var form = $(".event-form").clone().show();
var infowindow_content = form[0];
var infowindow = new google.maps.InfoWindow({
content: infowindow_content,
});