MySQL date formats - difficulty Inserting a date

后端 未结 5 1448
名媛妹妹
名媛妹妹 2020-12-23 19:39

I am trying to further a question I asked yesterday where I wanted to know how to query a date in a different format. But now I am trying to do an insert using this method (

5条回答
  •  悲&欢浪女
    2020-12-23 20:20

    When using a string-typed variable in PHP containing a date, the variable must be enclosed in single quotes:

    $NEW_DATE = '1997-07-15';
    $sql = "INSERT INTO tbl (NEW_DATE, ...) VALUES ('$NEW_DATE', ...)";
    

提交回复
热议问题