Home » Javascript » Cloud9 – MySQL DATETIME format

Cloud9 – MySQL DATETIME format

Posted by: admin June 30, 2018 Leave a comment


I am having an issue using the MySQL DATETIME format in Cloud 9.

MySQL reference states that the DATETIME format is YYYY-MM-DD HH:MM:SS, this is what I have done, but it keeps giving me a syntax error regarding the DATETIME format.

The error I’m getting is:

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 '. '2018-05-01 12:12:12')' at line 2

My JavaScript code (partial):

result = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
                var login = document.getElementById('login');

MySQL code:

$sql = "INSERT INTO Customer(customer_id, first_name, last_name, email, phone_home, phone_mobile, user_type_id, password, pasword_hashed, login)
VALUES ('', '$first_name', '$last_name', '$email', '$phone_home', '$phone_mobile', '$user_type_id', '$password', '$password_hashed'. '$login')";