wright67uk Posted April 25, 2013 Share Posted April 25, 2013 I'm using a jquery datepicker, that outputs dates in the following format 04/30/2013 I've set the date column in mysql table as a date type, however when I submit the above date to the table all I get is 0000-00-00 Do I need to replace the forward slashes with dashes, for this to work? also am I right to think that, as the submitted date contains slashes, I should be binding the date as a string? <?php //an extract from my code $stmt = $mysqli->prepare("INSERT INTO toptips VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param('isssssssss', $id, $time, $date, $course, $horse, $place, $odds, $description, $win, $tip); //end of extract ?> Link to comment https://forums.phpfreaks.com/topic/277317-binding-a-date-variable-and-inserting-to-sql-table/ Share on other sites More sharing options...
Dathremar Posted April 25, 2013 Share Posted April 25, 2013 I dont know what You have inside those params ($time, $date), but in order to get that date 04/30/2013 into a date field in the db you need to get it into this format: yyyy-mm-dd. Link to comment https://forums.phpfreaks.com/topic/277317-binding-a-date-variable-and-inserting-to-sql-table/#findComment-1426649 Share on other sites More sharing options...
seandisanti Posted April 25, 2013 Share Posted April 25, 2013 also, you should list the fields you're populating in parentheses after the table name, before the VALUES(...) Link to comment https://forums.phpfreaks.com/topic/277317-binding-a-date-variable-and-inserting-to-sql-table/#findComment-1426663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.