[eluser]otherjohn[/eluser]
Ok,so I am getting this error
"Fatal error: Call to a member function on a non-object in /home/domain/public_html/****/application/views/areacode_view.php on line 49"
My controller looks like this:
Code:
class PhoneNumbers extends Controller {
function PhoneNumbers()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
//$this->load->scaffolding('PhoneNumbers');
}
function areacode(){
$this->load->model('areacode_model','ac_db',True);
$this->load->view('areacode_view',$data);
}
function _formatNumber($format,$areacode,$number){
if($format ==1){
return "(".$areacode.") ".substr($number,0,3)."-".substr($number,3,4);
}else if($format == 2){
return $areacode."-".substr($number,0,3)."-".substr($number,3,4);
}else{
return $areacode.$number;
}
}
}
My Model is
Code:
class AreaCode_model extends Model {
function AreaCode_model()
{
parent::Model();
}
function get_All_Numbers()
{
if ($this->uri->segment(1) === FALSE)
{
$areacode = "000";
}
else
{
$areacode = substr($this->uri->segment(1),10,3);
}
$sql = "Select * from PhoneNumbers where areaCode=?";
$query = $this->db->query($sql,$areacode);
return $query->result();
}
}
And finally my areacode_view is
Code:
<?php foreach($query->result() as $row): ?>
<h3><?php echo $this->_formatNumber(1,$row->areaCode, $row->phone); ?></h3>
<p><?php echo anchor('../phonenumbers/numberpage/'.$this->_formatNumber(2,$row->areaCode, $row->phone),'Phone Number '.$this->_formatNumber(3,$row->areaCode, $row->phone)); ?></p>
<hr>
<?php endforeach; ?></ol>
OK so I don't understand why I am getting this error?
Can anyone see whats going on here?
NOTES:
uri->segment(1) would return area-code-555
so I extract the 555 out of it.
thanks