dpzp5127 2015-06-15 14:08
浏览 44

mysqli_query()需要至少2个参数,1在codeigniter中给出

While submitted form I am getting this error in codeigniter

severity: Warning

Message: mysqli_query() expects at least 2 parameters, 1 given

Filename: models/Login_model.php

Line Number: 50

Backtrace:

File: /opt/lampp/htdocs/zemco/application/models/Login_model.php
Line: 50
Function: mysqli_query

File: /opt/lampp/htdocs/zemco/application/controllers/Stock_main.php
Line: 42
Function: addCustomerDb

File: /opt/lampp/htdocs/zemco/index.php
Line: 292

Function: require_once

Controller:

public function __construct()
{
      parent::__construct();
      $this->load->library('session');
      $this->load->helper('form');
      $this->load->helper('url');
      $this->load->helper('html');
      $this->load->database();
      //load the login model
      $this->load->model('Login_model');
}

public function addCustomer(){
    $result = $this->Login_model->addCustomerDb();
}

Model:

public function addCustomerDb(){

    echo "INSERT INTO `tbl_customer` (customer_company_name, customer_primary_address1, customer_primary_address2, customer_primary_country, customer_primary_state, customer_primary_city, customer_primary_poboxno, customer_secondary_address1, customer_secondary_address2, customer_secondary_country, customer_secondary_state, customer_secondary_city, customer_secondary_poboxno, customer_landline, customer_fax, customer_internal_notes, customer_invoice_flag, customer_created_time, customer_created_by) VALUES('$comName', '$primaryAddressstreet1', '$primaryAddressstreet2', '$country1', '$state1', '$cityName1', '$poibox1', '$secondaryAddressstreet1', '$secondaryAddressstreet2', '$country2', '$state2', '$cityName2', '$poibox2', '$businessPhone', '$faxNumber', '$internalNotes', '$emailvia', '$createdOn', '1')";
    $query = mysqli_query("INSERT INTO `tbl_customer` (customer_company_name, customer_primary_address1, customer_primary_address2, customer_primary_country, customer_primary_state, customer_primary_city, customer_primary_poboxno, customer_secondary_address1, customer_secondary_address2, customer_secondary_country, customer_secondary_state, customer_secondary_city, customer_secondary_poboxno, customer_landline, customer_fax, customer_internal_notes, customer_invoice_flag, customer_created_time, customer_created_by) VALUES('$comName', '$primaryAddressstreet1', '$primaryAddressstreet2', '$country1', '$state1', '$cityName1', '$poibox1', '$secondaryAddressstreet1', '$secondaryAddressstreet2', '$country2', '$state2', '$cityName2', '$poibox2', '$businessPhone', '$faxNumber', '$internalNotes', '$emailvia', '$createdOn', '1')");
    $cid = $this->db->insert_id();
    echo $cid;

    $count = $this->input->post('contactCount');

    for($i = 1; $i <= $count; $i++){
        if($this->input->post('customerEmail1'.$i) != ''){
            $customerEmail = $this->input->post('customerEmail1'.$i);
            $customerPhone = $this->input->post('customerPhoneNumber'.$i);
            $customerMobile = $this->input->post('customerMobileNumber'.$i);
            $firstName = $this->input->post('firstName'.$i);
            $lastName = $this->input->post('lastName'.$i);

            $contAdd = mysqli_query("INSERT INTO `tbl_customer_contact` (customer_id, customer_contact_name, customer_contact_email, customer_contact_mobile, customer_contact_phone) VALUES('$cid', '$firstName"."$lastName', '$customerEmail', '$customerMobile', '$customerPhone')");
        }
    }

    if($query){
      //return 1;
    }
}

I am getting this error while doing form post in codeigniter. I dont know where I am lagging.

  • 写回答

2条回答 默认 最新

  • dongzhui9936 2015-06-15 14:16
    关注

    If you use mysqli_query as a function and not an method from a mysqli-object you have to pass the mysqli-link as the first parameter.

    php.net Manual mysqli.query

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)