When I add a record to the DB, I want the current date (in 0000-00-00 format) written to one of the fields. The field/column is of type “date” and correctly stores dates in this format if I manually insert their values. However, when I use the curdate() function, a date of 0000-00-00 is inserted instead. Here’s the INSERT:
$sql = "INSERT INTO Clients (ID, ContactName, Title, CompanyName, Address, Phone, Extension, Fax, Email, Website, InboundBox, OutboundBox, ProvideListBox, BothBox, InboundCalls, OutboundCalls, InboundMinutes, OutboundMinutes, SalesBox, AppointmentBox, LeadBox, MarketBox, CustomerServiceBox, CustomerRetentionBox, DatabaseBox, Other, BusinessBox, Titles, ConsumerBox, Begin, End, OngoingBox, Service, Budget, Comments, AddDate)
VALUES ('$ID', '$ContactName', '$Title', '$CompanyName', '$Address', '$Phone', '$Extension', '$Fax', '$Email', '$Website', '$InboundBox', '$OutboundBox', '$ProvideListBox', '$BothBox', '$InboundCalls', '$OutboundCall', '$InboundMinutes', '$OutboundMinutes', '$SalesBox', '$AppointmentBox', '$LeadBox', '$MarketBox', '$CustomerServiceBox', '$CustomerRetentionBox', '$DatabaseBox', '$Other', '$BusinessBox', '$Titles', '$ConsumerBox', '$Begin', '$End', '$OngoingBox', '$Service', '$Budget', '$Comments', 'CURDATE()')";
I also tried using the web mySQL client I have access to, to set the field to “curdate” as the client said I was doing and got the following… not as important if I can fix the above:
SQL-query :
UPDATE Clients
SET AddDate
= CURDATE(‘0000-00-00’) WHERE ID
= ‘2’ LIMIT 1;
MySQL said:
You have an error in your SQL syntax near ‘‘0000-00-00’) WHERE ID
= ‘2’ LIMIT 1’ at line 1
Thanks in advance for any help!