[eluser]penta997[/eluser]
Hi. I have a register form. I Have to write data into 3 tables. First table users, 2nd address and 3rd client. When function insert is running i have 2 errors:
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_result could not be converted to string
Filename: mysql/mysql_driver.php
Line Number: 535
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'jakas', 'jakas', '23', '2', '26-315', '2134324')' at line 1
INSERT INTO `address` (`Country_COUNTRY_Id`, `State_STATE_ID`, `USERS_USR_ID`, `ADDR_CityName`, `ADDR_StreetName`, `ADDR_StreetNr`, `ADDR_HomeNr`, `ADDR_ZIP`, `ADDR_Fax`) VALUES ('17', '4', , 'jakas', 'jakas', '23', '2', '26-315', '2134324')
This is my model code
Code:
function create_User()
{
$USR_ID = $this->db->query("select USR_ID from users where USR_Nick='".$this->input->post('username')."'");
$ADDR_ID = $this->db->query("select ADDR_ID from address where ADDR_StreetName='".$this->input->post('ulica')."'");
$users = array(
'USR_Nick' => $this->input->post('username'),
'USR_Pass' => md5($this->input->post('pass')),
'USR_CreateDate' => date('Y-m-d H:i:s')
);
$address = array(
'Country_COUNTRY_Id' => $this->input->post('country'),
'State_STATE_ID' => $this->input->post('state'),
'USERS_USR_ID' => $USR_ID,
'ADDR_CityName' => $this->input->post('ulica'),
'ADDR_StreetName' => $this->input->post('ulica'),
'ADDR_StreetNr' => $this->input->post('nr_ulicy'),
'ADDR_HomeNr' => $this->input->post('nr_domu'),
'ADDR_ZIP' => $this->input->post('kod_pocztowy'),
'ADDR_Fax' => $this->input->post('fax')
);
$client = array(
'Address_ADDR_ID' => $ADDR_ID,
'CLI_Email' => $this->input->post('email'),
'CLI_Name' => $this->input->post('imie'),
'CLI_LastName' => $this->input->post('nazwisko'),
'CLI_NIP' => $this->input->post('nip'),
'CLI_Regon' => $this->input->post('regon'),
'CLI_Pesel' => $this->input->post('pesel'),
'CLI_Phone' => $this->input->post('telefon')
);
$us = $this->db->insert('users', $users);
$add = $this->db->insert('address', $address);
$cli = $this->db->insert('client',$client);
$data = array('us' => $us, 'cli' => $cli, 'add' => $add);
return $data;
}