0

CODE:

public function addVendorForm($data,$db){
    $date = date('Y-m-d');
    $q = $db->prepare('INSERT INTO `rtl_vendor`(date,name,email,mobile_no,telephone_no,home_address_one,home_address_two,home_city,home_state,home_pincode,home_addr_proof,business_address_one,business_address_two,business_city,business_state,business_pincode,business_addr_proof,fax_no,website,contact_person_detail,account_person_detail,business_entity,business_commodity,pan_card,gst_certificate,annual_sales,vendor_references,employee_detail,director_detail,bank_name,bank_address,beneficiary_name,bank_acno,bank_ifsc,bank_cheque,notes,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');

    $q->bind_param('sssssssssssssssssssssiisssssssssssssi',$date,$data['name'],$data['email'],$data['phone'],$data['telephone'], $data['home_address_one'],$data['home_address_two'],$data['home_city'],$data['home_state'],$data['home_pincode'],$data['uploaded']['home_address_proof'],$data['business_address_one'],$data['business_address_two'],$data['business_city'],$data['business_state'],$data['business_pincode'],$data['uploaded']['business_address_proof'],$data['fax_no'],$data['website'],$data['contact_person'],$data['accounts_person'],$data['business_entity'],$data['business_commodity'],$data['uploaded']['pan_card'],$data['uploaded']['gst_certificate'],$data['annual_sales'],$data['vendor_references'],$data['employee_detail'],$data['director_detail'],$data['bank_name'],$data['bank_address'],$data['beneficiary_name'],$data['bank_acno'],$data['bank_ifsc'],$data['uploaded']['cheque_leaf'],$data['notes'],$data['status']);
    if($q->execute()) {
        return true;
    }
    return false;
}

Screenshot of My SQL Table:

enter image description here

Output: When I try to

var_dump($q->execute());

It returns

bool(false);

but $q->prepare() and $q->bind_param(); working (returns bool(true)) perfectly. I've tested my MySqli Object to but there is no error.

Totally 37 columns need to be added except id(AI) from 38.

Kindly help me to find out the mistake.

Solution:

public function addVendorForm($data,$db){
    $date = date('Y-m-d');
    $q = $db->prepare('INSERT INTO `rtl_vendor`(date,name,email,mobile_no,telephone_no,home_address_one,home_address_two,home_city,home_state,home_pincode,home_addr_proof,business_address_one,business_address_two,business_city,business_state,business_pincode,business_addr_proof,fax_no,website,contact_person_detail,account_person_detail,business_entity,business_commodity,pan_card,gst_certificate,annual_sales,vendor_references,employee_detail,director_detail,bank_name,bank_address,beneficiary_name,bank_acno,bank_ifsc,bank_cheque,notes,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');

    $q->bind_param('sssssssssssssssssssssiisssssssssssssi',$date,$data['name'],$data['email'],$data['phone'],$data['telephone'], $data['home_address_one'],$data['home_address_two'],$data['home_city'],$data['home_state'],$data['home_pincode'],$data['uploaded']['home_address_proof'],$data['business_address_one'],$data['business_address_two'],$data['business_city'],$data['business_state'],$data['business_pincode'],$data['uploaded']['business_address_proof'],$data['fax_no'],$data['website'],$data['contact_person'],$data['accounts_person'],$data['business_entity'],$data['business_commodity'],$data['uploaded']['pan_card'],$data['uploaded']['gst_certificate'],$data['annual_sales'],$data['vendor_references'],$data['employee_detail'],$data['director_detail'],$data['bank_name'],$data['bank_address'],$data['beneficiary_name'],$data['bank_acno'],$data['bank_ifsc'],$data['uploaded']['cheque_leaf'],$data['notes'],$data['status']);

    $q->execute();

    print_r($q->error); // Print the Error statement if any.
    exit;

    if($q->execute()) {
        return true;
    }
    return false;
}

In my case the error statement is - Column 'name' cannot be null.

Silambarasan R
  • 1,346
  • 15
  • 22

0 Answers0