CodeIgniter Tutorial News section |
(07-27-2015, 12:40 PM)Dracula Wrote:(07-27-2015, 09:00 AM)christaliise Wrote: I am now studying the News section - user_guide\tutorial\news_section.html - and having to spend many hours trying to understand, and where I expect I should be spending only around an hour on such simple instructions. Yeah right!
(07-29-2015, 01:32 PM)Wouter60 Wrote:Quote:(5) The 5th is difficult to understand. - The next thing to do is passing this data to the views. - I assume the code is to be pasted into News.php Thanks Wouter60, I'm grateful for your help. I'll need to study more to get the picture.
(07-28-2015, 08:33 AM)Wouter60 Wrote: Like @ciadmin suggested, the best way is to create the table with the database tool you are using, because this is just a one-time issue. I've deleted the sql-command from my News_model.php page and pasted it via phpmyadmin and created the table. I've inserted two records with titles, slug and text. And pointed my browser to http://localhost/MyProject/index.php/news BUT still get the HTTP 500 error. I assume each time I add code that it is to be added "before" the last curly brace }. I've tried moving the curly brace but no different. Any suggestions where I could be going wrong?
Check if your controller has multiple index() and view() functions in it. Your example code that you posted earlier this week shows that it does. Function names inside a class must be unique. When the documentation says that you have to add code to the index function in your controller, don't create a new function, but put the extra code before the closing curly brace of the existing index function. The same goes for the view() function.
Besides all that, you are not supposed to get an http 500 error, but a readable php error message on your localhost. Check your index.php file for the setting of the ENVIRONMENT constant. Does it say 'development' or 'production'? Development suppresses php error messages. That's fine when your website is online, but while you are writing, testing and debugging your application, you want to see what's going wrong, don't you? The http 500 error may also be caused by (a) bad server configuration or (b) an error in your .httaccess file. To check (a): type http://localhost in your browser. You should get the welcome page of your server. To check (b): rename your .htaccess file to .htaccess_org and try to start your website again. It should start the index.php file with your default controller. If you are still getting the same error, please upload your News.php file as an attachment to this topic.
(07-31-2015, 11:09 AM)Wouter60 Wrote: Check if your controller has multiple index() and view() functions in it. Your example code that you posted earlier this week shows that it does. Function names inside a class must be unique. When the documentation says that you have to add code to the index function in your controller, don't create a new function, but put the extra code before the closing curly brace of the existing index function. The same goes for the view() function. (1) Yes there were multiple index() and view() functions in News.php, so I've fixed that and now this is my current News.php file. Code: <?php After changing that I now get this error message An Error Was Encountered Unable to load the requested class: Authentication (2) I've checked C:/xampp/htdocs/MyProject/index.php and changed this line define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); to define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); but the results are no different however above that line it says NOTE: If you change these, also change the error_reporting() code below but there are 3 error_reporting() codes and I don't know which to change error_reporting(-1); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); (3a) When I point my browser to http://localhost I get the XAMPP Welcome message and the URL changes to http://localhost/xampp/ but you say I should get "welcome page of your server" so I guess that means Apache server. (3b) I've renamed 2 htaccess files to htaccess_org C:/xampp/htdocs/MyProject/htaccess_org C:/xampp/htdocs/MyProject/application/htaccess_org Having done all of that I still get the error message An Error Was Encountered Unable to load the requested class: Authentication I've searched many files but can't find a class named "Authentication".
I guess there is an autoload instruction for authentication. Check this in the file application/config/autoload.php.
PHP Code: $autoload['libraries'] = array(...);
(08-02-2015, 11:53 AM)Wouter60 Wrote: I guess there is an autoload instruction for authentication. Check this in the file application/config/autoload.php. Yes, there was reference to 'authentication' and I have removed it, and now have the following; Code: $autoload['libraries'] = array('database', 'email', 'session', 'table'); and I've tried removing the others, BUT I now get this same result whatever is the content; 404 Page Not Found The page you requested was not found. The page is at application/controllers/News.php and I'm pointing my browser at http://localhost/MyProject/index.php/news
There could be an error in your application/config/routes.php file.
Which routes did you declare in that file?
(08-03-2015, 10:45 AM)Wouter60 Wrote: There could be an error in your application/config/routes.php file. The routes.php is correct. I have solved the problem. I tried pointing my browser to http://localhost and back to http://localhost/MyProject/index.php/news but it made no difference but then I tried http://localhost/MyProject/index.php/pages/view, which worked OK and then back to http://localhost/MyProject/index.php/news, and then it worked!! I guess there is some error in my internal cache. Thanks for all your help. Reference to C:/xampp/htdocs/MyProject/index.php NOTE: If you change these, also change the error_reporting() code below Can you tell me which one of the 3 error_reporting() codes to change, and what to change it to? error_reporting(-1); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
In CI, the error reporting level depends on the ENVIRONMENT setting in index.php.
There is a line with this code: PHP Code: define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); If you're not sure about that, you can simply define the ENVIRONMENT constant like this: PHP Code: define('ENVIRONMENT','development'); PHP Code: define('ENVIRONMENT','production'); The first one is using the 'development' environment, the other one 'production'. When I upload my website, I make sure that on the hosted server, my index_production.php is renamed to index.php. A bit lower in index.php, you will see a "switch (ENVIRONMENT) { }" structure. With that, the correct error reporting level is set, depending on the value of the ENVIRONMENT constant. The different levels are explained here: http://php.net/manual/en/function.error-reporting.php |
Welcome Guest, Not a member yet? Register Sign In |