![]() |
load database blank screen - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: load database blank screen (/showthread.php?tid=795) |
load database blank screen - treadman - 01-18-2015 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'; RE: load database blank screen - Avenirer - 01-19-2015 Could you show the controller that uses the model? RE: load database blank screen - treadman - 01-19-2015 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'; RE: load database blank screen - Narf - 01-19-2015 You probably don't have the PHP mysql extension installed. RE: load database blank screen - treadman - 01-19-2015 (01-19-2015, 12:05 PM)Narf Wrote: You probably don't have the PHP mysql extension installed. No that's not it. phpinfo() show mysql and I wrote a little PDO script to read from a table. RE: load database blank screen - CroNiX - 01-21-2015 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. RE: load database blank screen - sneakyimp - 01-22-2015 (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. RE: load database blank screen - mwhitney - 01-28-2015 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. RE: load database blank screen - dbui - 01-30-2015 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 RE: load database blank screen - randy_rebucas - 01-31-2015 (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.'); } } |