Welcome Guest, Not a member yet? Register   Sign In
Error Number: 1048
#1
Sad 

I do not know why I get this error, can someone help me?


Quote:A Database Error Occurred
Error Number: 1048
Column 'file_id' cannot be null
INSERT INTO `bse_products_files` (`product_id`, `file_id`) VALUES (91, NULL)
Filename: /home/c3fctk/public_html/localhost/models/digital_product_model.php
Line Number: 94
and here is the line 94
Quote:
  • function associated($file_name, $product_id, $user_id)
  •     {
  •         $file_id = $this->db->where('title', $file_name)->where('user_id', $user_id)->get('digital_products')->row();
  •         $this->db->insert('products_files', array(
  •             'product_id' => $product_id,
  •             'file_id' => $file_id->id
  •         ));
  •     }
 line 94 


Quote: 'file_id' => $file_id->id


Reply
#2

Your error message says it all...
The bse_products_file schema says that the file_id column cannot be null.
The insert statement being executed does have null for file_id ...
INSERT INTO `bse_products_files` (`product_id`, `file_id`) VALUES (91, NULL)

Boom!

The root cause would appear to be that the "id" property of the row you find doesn't have a value, i.e. you are not finding a match for your query.
Reply
#3

(09-17-2019, 10:03 AM)ciadmin Wrote: Your error message says it all...
The bse_products_file schema says that the file_id column cannot be null.
The insert statement being executed does have null for file_id ...
INSERT INTO `bse_products_files` (`product_id`, `file_id`) VALUES (91, NULL)

Boom!

The root cause would appear to be that the "id" property of the row you find doesn't have a value, i.e. you are not finding a match for your query.
What should I do ? can you write me a fix? I am not a cooder, I do not know my way around.
Reply
#4

No, I won't write you a fix. If you "don't know your way around", then you need to get more proficient with PHP and CodeIgniter, or hire someone who can help. We are happy to help community members who get stuck, but do not provide a programming service, sorry.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB