0

My model file working on localhost but when I upload, it returns null values. Please explain to me how database.php is wrong.

My database.php:

$active_group = 'default';

$active_record = TRUE;

$db['default']['hostname'] = 'http://niation.com';

$db['default']['username'] = 'nire';

$db['default']['password'] = 'xxxxu23';

$db['default']['database'] = 'trrtuu';

$db['default']['dbdriver'] = 'mysql'

$db['default']['dbprefix'] = '';

$db['default']['pconnect'] = TRUE;

$db['default']['db_debug'] = FALSE;

$db['default']['cache_on'] = FALSE;

My model file:

<?php

class Play extends CI_Model
{

    function getdata()
    {
        $data = $this->db->select('info')->get('home');

         return $data->result();

    }

My controller file

class Nirmal extends CI_Controller {
public function about()
{
    $this->load->model('play');
    $data['info']=$this->play->getdata();
    $this->load->view('main1',$data);
}    

My view file

<?php foreach ($info as $item):?>
<p><?php echo $item->info;?></p>
<?php endforeach;?>
Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
  • I think it is similar issue to this one with [this](http://stackoverflow.com/questions/29904621/codeigniter-htaccess-and-configuration-when-uploading-website-to-server#comment-48054596) solution. – Tpojka May 13 '15 at 20:47

3 Answers3

0

I think your hostname is wrong, by default mysql connections are not through HTTP.

Check if you can connect to the database from your machine locally, check this similar question which may help you troubleshoot.

Community
  • 1
  • 1
thanedar
  • 51
  • 6
0

$db['default']['hostname'] = 'http://niation.com';

change this to $db['default']['hostname'] = 'localhost';

and then try to run

Umar Khan
  • 122
  • 8
0

simply update your default hostname.

$db['default']['hostname'] = 'localhost';

and then upload it to server,Then run website.