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"]));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器