Hi, I'm doing a simple application with CodeIgniter and sql 2000, which searches for records according to a client RUT, which is of type varchar.
model:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Prestaciones_model extends CI_Model
{
public function getHospitalizaciones($rut){
$query = $this->db->query('SELECT A.NRO_FI,A.FECHA FROM FICHA A,FIC_PAC B WHERE A.NRO_FI=B.NRO_FI AND B.RUT_NUM='.$rut.' ORDER BY A.FECHA DESC');
return $query->result();
}
}
The query is executed in the sql server manager, and if it works, but here I get this error:
Severity: Warning
Message: odbc_exec (): SQL error: [Microsoft] [ODBC SQL Server Driver] [SQL Server] Syntax error when converting nvarchar value '166-97' for a column of data type int., SQL state 22005 in SQLExecDirect
Filename: odbc / odbc_driver.php
Line Number: 138
Backtrace:
File: C: \ xampp \ htdocs \ Performances \ application \ models \ Performance_model.php Line: 7 Function: query
File: C: \ xampp \ htdocs \ Features \ application \ controllers \ Welcome.php Line: 17 Function: getHospitalizations
File: C: \ xampp \ htdocs \ Performances \ index.php Line: 315 Function: require_once
Looking at the bd '166-97' is a patient's rut, which is obviously wrong, but with all varchar records of that type I get the same error. But it's only with php since I tried the same in c # and if it works.
Any suggestions to solve this error?