• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->load->database($config); or $this->load->database(); Bug?

#1
[eluser]PHPstudio[/eluser]
Hi I'm getting some bug or something like that...

I have created controller and 5 views. Everything works fine until I add in constructor or in any other function inside controller this line "$this->load->database();"

Then I get a white screen - no errors no bugs but just white screen.

Code from controller:

<?php
class Miel extends CI_Controller
{

public function __construct()
{
parent::__construct();
// defaltut vrednosti, procesi, ...

// $this->db->querry('Nastavitve');
}

public function index()
{
$data['naslov'] = "Home";

$config['hostname'] = "localhost";
$config['username'] = "root";
$config['password'] = "yaq1yaq1";
$config['database'] = "test";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = FALSE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";

$this->load->database($config);

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/osnovna.php');
$this->load->view('oblika/noga.php');
}

public function home()
{
$data['naslov'] = "Home";

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/osnovna.php');
$this->load->view('oblika/noga.php');
}

public function shema()
{
$data['naslov'] = "Shema sistema";

//$this->load->model('Shema_model');


$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/shema.php',$data);
$this->load->view('oblika/noga.php');
}

public function grafi()
{
$data['naslov'] = "Grafi";

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/shema.php',$data);
$this->load->view('oblika/noga.php');
}

public function statistika()
{
$data['naslov'] = "Statistika";

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/shema.php',$data);
$this->load->view('oblika/noga.php');
}

public function nastavitve()
{
$data['naslov'] = "Nastavitve";

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/shema.php',$data);
$this->load->view('oblika/noga.php');
}

public function abaut()
{
$data['naslov'] = "Abaut";

$this->load->view('oblika/glava.php',$data);
$this->load->view('stran/shema.php',$data);
$this->load->view('oblika/noga.php');
}

}
?>

If you comment "$this->load->database($config);" line everything works fine.

#2
[eluser]Aken[/eluser]
Try setting db_debug to TRUE. Also, blank page usually means a PHP error, but error displaying has been suppressed in your app or in PHP.ini. Check index.php to turn error_reporting() on, and your PHP.ini file to make sure displaying errors is on.

#3
[eluser]PHPstudio[/eluser]
No difference, still don't work.
PHP.ini file? or you mean index.php file?

define('ENVIRONMENT', 'development');
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;

case 'testing':
case 'production':
error_reporting(0);
break;

default:
exit('The application environment is not set correctly.');
}
}
So I should see all errors?

Also I'm been wondering are there any good/correct tutorials? Because I copy paste code from tutorials and stuff don't work.

This is my log file...

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>

ERROR - 2012-08-25 22:23:34 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:34 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:34 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:37 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:37 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:37 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:42 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:42 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:42 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:46 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:46 --> 404 Page Not Found --> errors/page_missing
ERROR - 2012-08-25 22:23:46 --> 404 Page Not Found --> errors/page_missing

#4
[eluser]CroNiX[/eluser]
In your case statement for "development", try adding
Code:
ini_set('display_errors', 1);

#5
[eluser]PHPstudio[/eluser]
Still no difference.

Can you tell me how and where you load database driver?
I have added
Code:
$this->output->enable_profiler(TRUE);
in controller.
So under page I get some information. And on pages which work fine I get message: QUERIES Database driver is not currently loaded.

(You load database driver with "$this->load->database();" line? How to load database driver globally? You add "$this->load->database();" line in constructor? In video tutorial database driver is loaded globally, but video tutorial has been made with CodeIgniter 1.x version. So this still works in 2.x versions?)

#6
[eluser]Aken[/eluser]
You can autoload it with your libraries, or call $this->load->database() somewhere before you perform your queries.

http://ellislab.com/codeigniter/user-gui...cting.html

#7
[eluser]PHPstudio[/eluser]
When I modified
Code:
$autoload['libraries'] = array('database');
line in autoload.php whole page stopped working.

Is possible that firewall is giving me problems? Or something like that?
With MySQL Workbench I can easy connect to MySQL database.

I'm using Linux Mint Chinamon 13. Web page runs on apache2 package and php5.

#8
[eluser]Unknown[/eluser]
I had also the same issue, I solved it by changing db driver:

from:
$db['example']['dbdriver'] = "mysql";

to:

$db['example']['dbdriver'] = "mysqli";


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.