views:

358

answers:

1

Hello,

I have a codeigniter code that is working on local Apache installation. But it does not work on Godaddy Hosting.

I have got other similar views and controllers which are working on Godaddy.

Following is the code. I have pasted only relevant code.

Controller:

function index() { $this->load->model('Feedmodel'); $data['posts']=$this->Feedmodel->gethomedata(); $this->load->view('home',$data); }

View: PHP CODE ONLY

foreach($posts as $post){

    echo $post['url'];  

}

The error that I am getting is

A PHP Error was encountered Severity: Notice

Message: Undefined variable: posts

Filename: views/home.php

Line Number: 59

A PHP Error was encountered Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/home.php

Line Number: 59

The same code is working fine with other controllers and views...

A: 

The reason that you are getting an error notice in the GoDaddy environment and not in your local installation is most probably because of different error reporting in the two php installations. Edit your local php.ini and index.php in the root codeigniter dir and verify that error_reporting(E_ALL); exists.

Also are you using the foreach loop to iterate through all the HTTP POST variables? if so try changing it to

foreach($_POST as $post){

    echo $post;

} 

you could also use codeigniter's input library to do this.

$post_url = $this->input->post('url');

Iraklis