[eluser]sasori[/eluser]
I created a folder named "file" outside the system folder.
now here's my controller function
Code:
function add()
{
$data['words'] = $this->stock_model->putData("files/testtext.txt");
$this->load->view('success',$data);
}
and this is my model function to read the file
Code:
function putData($txt)
{
$handle = file_get_contents($txt);
$var_array_parent = explode("\n",$handle);
foreach($var_array_parent as $value)
{
$var_array = explode(";",$value);
$a = array_chunk($var_array,4);
for($i=0;$i<sizeof($a);$i++)
{
$a[$i][1] = preg_replace("/\s\%/","%",$a[$i][1]);
$data = array(
'compcode' => $a[$i][0],
'pricepercent' => $a[$i][1],
'compname' => $a[$i][2],
'volume' => $a[$i][3]);
$this->db->insert('stocks',$data);
}
}
return $this->db->affected_rows();
}
now am getting this error
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$stock_model
Filename: controllers/welcome.php
Line Number: 23
Quote:Fatal error: Call to a member function putData() on a non-object in C:\xampp\htdocs\myapp\system\application\controllers\welcome.php on line 23
please tell me what to do ?