dqx76962 2013-08-02 22:05
浏览 150
已采纳

是这样的数据库 - 0000-00-00 00:00:00

it is such that I have trouble lying 2 inputs together in a and after just it into the database

the problem is when it comes to the database looks like this 0000-00-00 00:00:00

this is how I have chosen to keep the date and time apart to make it simple as possible.

function tilmeldAdmin()
{
    if ($stmt = $this->mysqli->prepare('INSERT INTO `tilmeldt` (`title`, `info`, `Dato`,  `antal`, `opret_navn`, `opret_email`, `opret_id`) VALUES (?, ?, ?, ?, ?, ?, ?)')) { 
        $stmt->bind_param('sssissi', $title, $info, $Dato, $antal, $opret_navn, $opret_email, $opret_id);
        $title = $_POST["title"];
        $info = $_POST["info"];
        $Dato = $_POST["dob"] . $_POST["time"];//Here is error when it should be entered into the database (Everything else works just fine with no problems)
        $antal = $_POST["antal"];
        $opret_navn = $_SESSION["navn"];
        $opret_email = $_SESSION["mail"];
        $opret_id = $_SESSION["id"];
        $stmt->execute();
        $stmt->close();
    }
}
  • 写回答

1条回答 默认 最新

  • douchu5131 2013-08-02 22:11
    关注

    Assuming you are getting the date in YYYY-mm-dd format and the time in HH:ii:ss your issues is you are missing a space between the two elements.

    $Dato = $_POST["dob"] .' '. $_POST["time"];
    

    If you are being provided the date in a relatively sane manner you can use strtotime to get the date in the format you want.

    $Dato = date("Y-m-d H:i:s", strtotime($_POST["dob"]." ".$_POST["time"]));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!