For hairs you cannot insert a date ("y-m-d h:i:s") into a field of type DateTime,

Source: Internet
Author: User
For hairs you cannot insert a date ("y-m-d h:i:s") into a field of type DateTime,
What kind of timestamp can it be?

$re =mysql_query (' INSERT into ook (XX) VALUES (date ("y-m-d h:i:s"));


Reply to discussion (solution)

$re = mysql_query (' INSERT into ook (XX) VALUES (\ '. Date ("Y-m-d h:i:s"). ' \')');

In single quotation marks, the date function cannot parse the

Get a variable.
$date =date ("y-m-d h:i:s");
and put it in the SQL.

You use Date ("y-m-d h:i:s") just a conversion to the database Date field content format, you do not give it the field name is of course wrong.

$re = mysql_query ("INSERT into ook (XX) VALUES ('). Date ("Y-m-d h:i:s"). "')";
SQL statements are easier to use with "double quotes, because the insertion of a number other than the shape of the shape will have to use the ' single quotation mark
There is the general insertion of the value of the ' single quotation mark is better, too lazy to think whether it should be added single quotation mark problem

I thought the double quotes could parse the variable,
You can also parse the execution of a function:

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.