Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter 3 Use of undefined constant VIEWPATH - assumed 'VIEWPATH'

I've built a system using Codeigniter 3 and for some reason, only some users are getting a white screen. I'm trying to debug it and have logging turned up.

I'm getting the following errors in my logs:

Severity: Notice --> Use of undefined constant VIEWPATH - assumed 'VIEWPATH' /my/server/path/to/system/core/Common.php 196
Severity: Notice --> Use of undefined constant VIEWPATH - assumed 'VIEWPATH' /my/server/path/to/system/core/Exceptions.php 162
Severity: Warning --> include(): Failed opening 'VIEWPATHerrors/html/error_general.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') /my/server/path/to/system/core/Exceptions.php 182

So it seems that the core php files can't see the defined vars from the index file. But what's odd is if I define VIEWPATH at the top of Common.php it errors saying that VIEWPATH is already set. I added a log_message to my controller to output my VIEWPATH setting and it seems to work just fine.

I can't figure out how to get past this. Any ideas?

like image 986
Andrew Christensen Avatar asked Nov 28 '22 10:11

Andrew Christensen


2 Answers

This is usually caused by not updating the index.php from an older version when upgrading CodeIgniter. The easy fix is to download the index.php file from the version you are upgrading to and replace the old index.php with it.

like image 186
Isaac Pak Avatar answered Dec 04 '22 09:12

Isaac Pak


Thanks @abdulla, however, I found the problem. The index.php file was being bypassed for only some users that were somehow going to an old differently named file that was based on the CI2 build we did previously.

If anyone else runs into this problem, check to make sure you don't have any other "index" files in your root that users may be getting to.

like image 35
Andrew Christensen Avatar answered Dec 04 '22 08:12

Andrew Christensen