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

11
  • Blank screen is the "Error of Death". Look into the error log or enable error reporting in CodeIgniter. Commented Apr 3, 2017 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 Commented Apr 3, 2017 at 16:52
  • the name of the controller is index.php Commented Apr 3, 2017 at 17:08
  • @DFriend just editted my question Commented Apr 3, 2017 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? Commented Apr 3, 2017 at 19:52

1 Answer 1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.