load database blank screen |
I get a blank screen when it tries to do load->database(). No error message. Nothing in the log. I verified that the database hostname, username, password and database are all correct using MySql Workbench.
I saw a post somewhere saying that CodeIgniter should not use PHP > 5.3. Could that be it? I have PHP 5.6.1 and CI 2.2 This is the model/news_model.php (from the news blog tutorial): Code: <?php This is config/database.php: Code: $active_group = 'default';
Could you show the controller that uses the model?
Website: http://avenir.ro
Thanks for the reply. Here is some more code.
The controller, news.php: Code: class News extends CI_Controller { In routes.php: Code: $route['news/(:any)'] = 'news/view/$1';
You don't load the database from within a model. Do it in autoload (best since I bet most of your app uses db), or in the controller before loading/using the model.
(01-19-2015, 01:54 PM)treadman Wrote:(01-19-2015, 12:05 PM)Narf Wrote: You probably don't have the PHP mysql extension installed. This may still be correct. the mysql extension has been deprecated and you should not use it. Try mysqli (stands for mysqli improved) instead. I can't seem to locate any documentation links that describe what all the valid options are. The CI 3 docs look fairly helpful. EDIT: just to be clear, the old mysql extension may not exist in your new PHP version. You would still see some MySQL configuration information in phpinfo, but that would be referring to mysqli ("MySQL Improved") or perhaps PDO or something.
Additionally, a PDO script may not tell you that the mysql extension is not installed, because PDO does not have to use the mysql extension in newer versions of PHP.
try this simple test
Add this function to your controller /** */ function test_db($terms){ if($terms){ $obj = $this->news_model->get_news($terms); // this should return array as per your model code print_r($obj); //should show array output if the term is found in query } else{ print 'no terms param is passed on'; } } /* end test func*/ If you can see the output per 'terms' passed to controller then you have failed to iterate the array in your view, check your code The testlink url should be in this format http://yournameserver/news/test_db/anyterm OR http://yournameserver/index.php/news/test_db/anyterm depends on how you set up your codeigniter site Good luck
(01-30-2015, 10:24 PM)dbui Wrote: try this simple test Enable log error or copy this to your index.php if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': // Report all errors //error_reporting(E_ALL); // Display errors in output //ini_set('display_errors', 1); error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); break; case 'testing': case 'production': //error_reporting(0); ini_set('display_errors', 1); // This will turn error reporting on error_reporting(E_ALL); break; default: exit('The application environment is not set correctly.'); } } |
Welcome Guest, Not a member yet? Register Sign In |