1

I have a controller to send data to a index page of php in my codeigniter application as shown

this is the snippet of code from the controller

I have added an echo which I can see from the console

EDITTED

this is the beginning of the index controller

<?php  if(! defined("BASEPATH")) exit("no direct acces to script");

//this is the index 

class Index extends CI_Controller
{


   }

function index()
   {
        echo("Am here");

       if($this->session->userdata("user_public_id"))
       {
       $user_id = $this->session->userdata("user_public_id");
       }
       else
       {
       $user_id = "0";
       }


            </div>     
            <?php endforeach; ?>

I cannot figure out why is my page showing no content. Kindly assist me in debugging this

Cœur
  • 37,241
  • 25
  • 195
  • 267
parker
  • 255
  • 2
  • 6
  • 21
  • Blank screen is the "Error of Death". Look into the error log or enable error reporting in CodeIgniter. – Bikram Pahi Apr 03 '17 at 16:32
  • Please show the code at the very start of the controller where the above index method is found. Also, what is the the exact file name of the controller? (exact === including the case of all characters) Also, check the controller file for an extraneous BOM at the very beginning of the file. [BOM info here](https://www.w3.org/International/questions/qa-byte-order-mark) – DFriend Apr 03 '17 at 16:52
  • the name of the controller is index.php – parker Apr 03 '17 at 17:08
  • @DFriend just editted my question – parker Apr 03 '17 at 17:31
  • Is this file located in the root directory of your CI installation? Or maybe I should ask it this way: Where is this file located - what folder relative to the root of your website? – DFriend Apr 03 '17 at 19:52
  • I would not name controller Index rename it to some thing else like Home because there is already a index.php in main directory –  Apr 03 '17 at 21:13
  • @DFriend it is located here >>>> mywebsite/global_app\controllers – parker Apr 03 '17 at 21:48
  • Try changing the file name from index.php to Index.php - note the first letter is uppercase. But @wolfgang1983 is correct, you should use some other name for the class besides Index. – DFriend Apr 03 '17 at 21:59
  • ok did that and applied background color and it effected the color but it not rendering the content of the loop – parker Apr 03 '17 at 22:02
  • my problem has been resolved thanks to you all. what I did was to check the files calling the database – parker Apr 03 '17 at 22:35
  • Possible duplicate of [PHP's white screen of death](http://stackoverflow.com/questions/1475297/phps-white-screen-of-death) – miken32 Apr 03 '17 at 23:03

1 Answers1

1

@parker As per your code, the index() function is placed at outside of the controller, it should be inside in the Index Class, like this

<?php  if(! defined("BASEPATH")) exit("no direct acces to script");

//this is the index 

class Index extends CI_Controller
{    


function index()
   {
        echo("Am here");

       if($this->session->userdata("user_public_id"))
       {
       $user_id = $this->session->userdata("user_public_id");
       }
       else
       {
       $user_id = "0";
       }
       .
       .
       .
       .
}
 ?>

If the problem still exist, please do change the name of the controllerIndex to Something else!

This may helps you..thanks!

Abdul Salam
  • 406
  • 2
  • 15