Codeigniter, blank page, no errors [closed]

核能气质少年 提交于 2020-01-21 05:49:04

问题


public function newreg()
    {
        $username = $this->input->post('username');
        $password = $this->input->post('password');

        $this->load->model('register_model');

        $data['list']=$this->register_model->add($username, $password);

        $this->load->view('register_display', $data);
    }

This is part of a controller named register.php once this function gets called, all I see on the screen is white space.

This function is an exact copy of a working one, from a working controller. Only the file names are changed (model, view)

I can't figure out where the problem is.


回答1:


You can easly check what's happening in the enteire envoirment by enalbing CI logs,

go to config/config.php and edit this:

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|   0 = Disables logging, Error logging TURNED OFF
|   1 = Error Messages (including PHP errors)
|   2 = Debug Messages
|   3 = Informational Messages
|   4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/


  $config['log_threshold'] = 0; //put this to 4

then if you have not yet a /logs folder inside your /application folder, create that and add 775 chmod to that (logs folder only).

UPDATE: You must also chown apache:apache logs in order for apache to be able to write within that folder.

run your application by the browser and check inside your /logs folder the log.php file, it will contain all the application errors.




回答2:


To see the errors instead of a white page, you need to change two options in the php.ini file:

  • error_reporting to E_ALL
  • display_error to On

See this answer for more information.




回答3:


if you changed the file names, you also need to change the class names:

A file named my_class.php needs to have: class My_class extends CI_Controller {

so, if you took a working controller, copied it, and renamed the file. Then you also need to rename the class.



来源:https://stackoverflow.com/questions/14165283/codeigniter-blank-page-no-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!