Welcome Guest, Not a member yet? Register   Sign In
What is causing the error in Codeigniter 4?
#1

I am trying to load the booking.php file using Codeigniter 4, but encountering an error. I have added the required code to the Home Controller, but the page does not show up. When I call the file at sitename.com/booking, it returns an error. However, I am able to call index.php successfully. I am unable to call other URLs like /booking or /contact. Here is the code that I have added to the Home Controller:


public function booking()
{
$this->load->view('Partials/home/head');
$this->load->view('Home/booking');
$this->load->view('Partials/home/foot');
}

public function index()
{
echoview('Partials/home/head');
echoview('Home/index');
echoview('Partials/home/foot');
}
Reply
#2

Did you configure routes?
Reply
#3

in CodeIgniter 4 you should use
return view('Partials/home/head')
..
CodeIgniter 3
$this->load->view('Partials/home/head')
Reply
#4

Your using CodeIgniter 3 code where you should be using CodeIgniter 4 code.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

Firstly, have you checked to make sure that the "booking.php" file is located in the correct directory and has the correct file name? Additionally, have you checked to make sure that the file permissions for the "booking.php" file are set correctly?

Another thing to check is the routing configuration in CodeIgniter. Make sure that you have defined a route for "/booking" in the "app/Config/Routes.php" file. You can define a route like this:

$route['booking'] = 'Home/booking';

If none of these solutions work, you may want to consider checking the error logs to see if there are any specific error messages that can help diagnose the issue.
Reply
#6

PHP Code:
echoview();
// should be
echo view(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

It looks like you're having trouble loading the booking.php file using Codeigniter 4. From your code snippet, it seems that you have added the necessary code to the Home Controller. However, when you try to access the booking page at sitename.com/booking, you encounter an error. It could be that the URL is not configured properly in your routing file. Have you made sure that the route for the booking page is defined in your routes.php file? You can try adding the following line to your routes file: `$routes->get('booking', 'Home::booking');` This will map the URL `sitename.com/booking` to the `booking()` method in your Home Controller. Once you have added the route, you should be able to access the booking page without any issues.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB