Models won't load |
None of my models will load. No matter which one. I've tried different names, but I always get: "An Error Was Encountered
Unable to locate the model you have specified.” I'm at a loss. /models/menu_model.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /controllers/welcome.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
You named your model Menu_model so you need to load it as Menu_model not just Menu.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Just wondering, why are you including this line at the top of your model and controller?
PHP Code: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Thanks!
Also, when I check my developer tools, I keep getting "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"
Are you checking your server error log file?
The location of that file depends on the server used. Apache (linux) is usually in /var/log/apache2.error.log Also, change the model name (menu -> Menu_model) in ALL uses in your Welcome controller, I found two uses in the code posted above. The name is case sensitive on most OS's.
CI 3.1 Kubuntu 19.04 Apache 5.x Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing. Clarity is desirable over Brevity every time.
Okay, let me lay this out again. I'm developing on OpenShift by Red Hat. I've setup application just as the tutorial/walkthrough says to. I can't get models to load, and I keep getting a 500 error. I've checked the log files.
When I load the webpage I get this in the logs: Code: [08/Dec/2014:20:13:52 -0500] "GET / HTTP/1.1" 500 - "http://2scsb-aaronfenker.rhcloud.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25" If the filename of my model includes "_model, “ the page gives the CI error message, but it still throws the 500 error. If I don't include "_model" in the filename, then the page doesn't load at all, but it still throws the 500 error. When I do a git push I get the following errors: Code: [08/Dec/2014:20:11:04 -0500] "HEAD / HTTP/1.1" 500 - "-" "Ruby" I deleted my original app, and started fresh just in case I goofed on something in pushes. (Git is new to me too.) Here's my code again. controllers/welcome.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); models/nav_menu.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Is there a setting that I'm missing somewhere?
I guess you are using CI 2 so...
Try this in you controller - i just changed the model name to nav_m PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); And this in your model but don't forget to change the file name of the model in nav_m.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro (12-08-2014, 06:21 PM)afenker1985 Wrote: Okay, let me lay this out again. I'm developing on OpenShift by Red Hat. I've setup application just as the tutorial/walkthrough says to. I can't get models to load, and I keep getting a 500 error. I've checked the log files. Also set your methods in model to public.
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro |
Welcome Guest, Not a member yet? Register Sign In |