dadamssg Posted April 4, 2009 Share Posted April 4, 2009 i have a piece of a script that builds a start date selection list and it has a predefined variable determine which month/day/year is selected...here it is <?php $smonth = array(1=> "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); echo "<select name='smonth'>\n"; for ($n=1;$n<=12;$n++) { echo "<option value=$n\n"; if ($mo == $n) { echo " selected"; } echo "> $smonth[$n]\n"; } echo "</select>\n"; /* build selection list for the day */ $todayDay= $_POST['sday']; //get the day from $today echo "<select name='sday'>\n"; for ($sday=1;$sday<=31;$sday++) { echo " <option value=$sday"; if ($da == $sday ) { echo " selected"; } echo "> $sday\n"; } echo "</select>\n"; /* build selection list for the year */ $today = time(); $selected = $_POST['syear']; $startYr = date("Y", $today); //get the year from $today echo "<select name='syear'>\n"; // get the date you want to end up at for ($syear=$startYr;$syear<=$startYr+1;$syear++) { echo " <option value=$syear"; if ($yr == $syear ) { echo " selected"; } echo "> $syear\n"; } echo "</select>\n";?> and then i do this in my other processing script $sts = mktime($sh,$_POST['sminute'],0, $_POST['smonth'], $_POST['sday'], $_POST['syear']); $ss = date('Y-m-d H:i:s',$sts); but for some reason the date isn't getting posted i get this error when i try to insert $ss as a datetime You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '18:15:00 WHERE eventid=277' at line 1 so its grabbing the time correctly, but no date..can anyone see a problem in my date building? Link to comment https://forums.phpfreaks.com/topic/152511-_post-not-getting-set/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 4, 2009 Share Posted April 4, 2009 DATETIME values are strings and must be enclosed in single-quotes in a query. Did you echo out $ss or the query to see what exactly is in it? Link to comment https://forums.phpfreaks.com/topic/152511-_post-not-getting-set/#findComment-801033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.