Search code examples
phpmysqldatestore

Storing date in MySQL


I want the date to be added to an orders table I have created, once the user proceeds to checkout. The code I currently has just prints:

"Error: Column count doesn't match value count at row 1"

Here's my code:

$sql = "INSERT INTO orders (customer_id, total, order_date) VALUES ('$name', '$total', 'DATETIME: Auto NOW()', NOW() )";

The name and total columns store but the date does not. How can I solve this?


Solution

  • This way:

    $sql = "INSERT INTO orders (customer_id, total, order_date) VALUES ('$name', '$total', NOW())";