Issue
We have a form that adds products to our database. We have here in a open_form_multipart for the images. We think that the problem is that it doesn't add our attributes.
error:
Error Number: 1048
Column 'product_foto' cannot be null
INSERT INTO
products(product_naam,product_beschrijving,product_categorie,ophaal_plaats,product_foto,date_created,date_updated) VALUES ('', '', '', '', NULL, '2017-06-20', '2017-06-20')Filename: models/Product_model.php
Line Number: 9
our code is in the view:
<?php
echo $this->session->flashdata('msg');
echo form_open_multipart('name="product_foto"');
echo form_upload('file');
echo form_submit('upload', 'Upload');
?>
Solution
You need to follow conventions for defining form.
Your code should be:
$arr = array('name' => 'product_foto');
echo form_open_multipart('', $arr);
form_open_multipart([$action = ''[, $attributes = array()[, $hidden = array()]]])
Parameters:
$action (string) – Form action/target URI
string $attributes (array) – HTML attributes
$hidden (array) – An array of hidden fields’ definitions Returns: An HTML multipart form opening tag
Return type: string
Note: Action is set blank so that the the form will submit to the same page.
Answered By - Pupil
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.