Re: Still Having Problems with DATE....
I tried "", `` and ''.....still fails.
The form:
<label for="Date">Today's Date: </label><input id="Date" type="date" name="currentdate" /> <label for="Date"><span style="color:red">Survey Due Date:</span> </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)