1

I am trying to insert a record with one field as NULL but is return an ERROR:Column 'paid' cannot be null

NOTE: In Database table column paid is of type integer.

CODE

$sql="INSERT INTO `fees_receipt_temp_table`(`id`, `voucher_no`, `std_id`, `full_name`, `payable_fee`,paid) VALUES ('','$voucher_no','$std_id','$name','$payable',NULL)";
2
  • 2
    It isn't the dataype. You need to check if the column 'paid' allows NULL. Share your table schema if possible Commented Feb 15, 2017 at 9:19
  • 1
    check your database structure. you probably set the column 'paid' to NOT NULL. remove the constraint Commented Feb 15, 2017 at 9:19

2 Answers 2

3

It's in your database table settings. If the column is set to be "NOT NULL", clear that constraint.

Sign up to request clarification or add additional context in comments.

1 Comment

Works for me thanks,
1

The database column is set on NOT NULL. Because of this the column does not accept NULL values.

If you wanna allow NULL as an option, you can alter it to run the following query.

ALTER TABLE fees_receipt_temp_table
ALTER COLUMN paid INT IS NULL

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.