MySQL Forums
Forum List  »  Newbie

Re: INSERT INTO NULLABLE FIELDS THROWING ERRORS WITH NULL VALUES
Posted by: Peter Brawley
Date: September 16, 2014 03:02PM

> TAX = '',
> INVOICE_TOTAL = '',
> DATE_SENT = '',

Right, they're empty strings rather than nulls, but tax and invoice_total and date_sent ain't strings, so you need something like ...

if( $tax=='') $tax='null';
if( $invoice_total=='' ) $invoice_total='null';
if( $date_sent=='' ) $date_sent='null';

then ...

$query = "insert ... set ... tax=$tax, invoice_total=$invoice_total, date_send=$date_sent,..."

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

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.