在提交表单时,我在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
功能:require_once
控制器:
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();
}
型号:
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;
}
}
我在codeigniter中执行表单发布时遇到此错误。我不知道我在哪里滞后。
答案 0 :(得分:2)
我犯了小错误,谢谢你的回复。 我试过了,
$query = mysqli_query("");
替换为
$query = $this->db->query("");//i used this code
我再一次感谢你们。
答案 1 :(得分:0)
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.