MySQL Forums
Forum List  »  Newbie

Re: Still Having Problems with DATE....
Posted by: Raymond Jender
Date: June 21, 2021 06:17AM

I tried "", `` and ''.....still fails.

The form:

<label for="Date">Today's Date:&nbsp;</label><input id="Date" type="date" name="currentdate" /> &nbsp;&nbsp;<label for="Date"><span style="color:red">Survey Due Date:</span>&nbsp;</label><input id="Date" type="date" name="surveyduedate" Required />

The PHP:

$sql = "INSERT INTO `orderform` ( jobnumber, year, month, currentdate, 'surveyduedate') VALUES ($updatejobnumber, $currentyear, $currentmonth, CURDATE(), $surveyduedate)";

Fatal error: Uncaught mysqli_sql_exception: 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 ''surveyduedate') VALUES (21060041, 21, 06, CURDATE(), 2021-06-29)' at line 1 in /var/www/html/orderform/insert.php:132 Stack trace: #0 /var/www/html/orderform/insert.php(132): mysqli_query() #1 {main} thrown in /var/www/html/orderform/insert.php on line 132

The values printed in the error msg are correct. When I delete the $surveyduedate logic, CURDATE() works fine as indicated in id 65 below:

$sql = "INSERT INTO `orderform` ( jobnumber, year, month, currentdate ) VALUES ($updatejobnumber, $currentyear, $currentmonth, CURDATE())";

mysql> select * from orderform;
+----+-----------+------+-------+-------------+---------------+
| id | jobnumber | year | month | currentdate | surveyduedate |
+----+-----------+------+-------+-------------+---------------+
| 1 | 21060001 | 21 | 06 | NULL | NULL |
| 65 | 21060043 | 21 | 06 | 2021-06-21 | NULL |
+----+-----------+------+-------+-------------+---------------+
2 rows in set (0.00 sec)

(Ignore the "year" and "month" in the query as I use them for another reason)

Server version: 8.0.25-0ubuntu0.20.04.1 (Ubuntu)

Options: ReplyQuote


Subject
Written By
Posted
Re: Still Having Problems with DATE....
June 21, 2021 06:17AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.