Welcome Guest, Not a member yet? Register   Sign In
HTTP Error 500 on Google Chrome, Blank on Iceweasel
#1

[eluser]fredmanglis[/eluser]
I am new to CodeIgniter, and was going through the tutorial that comes with the user guide.

I am experiencing a problem on the 'News Section' where, after I have done as the tutorial states, I get the HTTP Error 500 on Google Chrome (Version 22.0.1229.94) and a blank document on Iceweasel (10.0.7).

I have set up the database configuration in 'application/config/database.php' according to instructions, and even tried different servers (Postgresql 9.1 and MySQL 5) to no avail.

I am officially stumped, and I would appreciate any assistance to get me out of my current ignorance level.

In case it is relevant, I am running on Debian 7 (Wheezy).

Thank you for your time.
#2

[eluser]satej[/eluser]
Can you please be a little more explicit stating your problem in terms of links, error message, image etc.? Smile
#3

[eluser]fredmanglis[/eluser]
The problem comes in after pointing my browser to the path localhost/CodeIgniter_2.1.3/index.php/news

The routing rules (according to the tutorial) are to be set up as follows:
Code:
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

Google Chrome responds with:
'The website encountered an error while retrieving http://localhost/CodeIgniter_2.1.3/index.php/news. It may be down for maintenance or configured incorrectly'

'HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.'
The other code that i did was:

applications/models/news_model.php
Code:
<?php
class News_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}

        public function get_news($slug = FALSE)
        {
         if ($slug === FALSE)
         {
          $query = $this->db->get('news');
          return $query->result_array();
         }

         $query = $this->db->get_where('news', array('slug' => $slug));
         return $query->row_array();
        }
}
?>

application/controllers/news.php
Code:
<?php
class News extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model('news_model');
}

public function index()
        {
         $data['news'] = $this->news_model->get_news();
         $data['title'] = 'News archive';

         $this->load->view('templates/header', $data);
         $this->load->view('news/index', $data);
         $this->load->view('templates/footer');
        }

public function view($slug)
        {
         $data['news_item'] = $this->news_model->get_news($slug);

         if (empty($data['news_item']))
         {
          show_404();
         }

         $data['title'] = $data['news_item']['title'];

         $this->load->view('templates/header', $data);
         $this->load->view('news/view', $data);
         $this->load->view('templates/footer');
        }

}
?>

application/views/news/index.php
Code:
<?php foreach ($news as $news_item): ?>

    <h2>&lt;?php echo $news_item['title'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $news_item['text'] ?&gt;
    </div>
    <p><a href="news/&lt;?php echo $news_item['slug'] ?&gt;">View article</a></p>

&lt;?php endforeach ?&gt;

application/views/news/view.php
Code:
&lt;?php
        echo '<h2>'.$news_item['title'].'</h2>';
        echo $news_item['text'];
?&gt;
#4

[eluser]satej[/eluser]
@fredmanglis

I used your code and was able to see the something similar to this image

https://lh4.ggpht.com/JKZF8MyLcN-lzbabDz...TWvLa=s136

and there was no error as such you have mentioned. Are you using any api that calls to Google or something?

The error you are entering may not be a CodeIgniter syntax error. Is there anything else about your code, you would like to share that may help us find a solution to it?
#5

[eluser]fredmanglis[/eluser]
Thanks @satej for your response. I am not using any other APIs, at least, not any that I am aware of.

My setup is on a personal machine with Apache/2.2.22 on Debian 7 (Wheezy), with PHP 5.4.4-9.
I have placed the "CodeIgniter_2.1.3/" directory in the "/var/www/" directory.

I am not aware of anything else that could be the problem. After setting the log_threshold=4; (ALL), I get the following output:

Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?&gt;;

DEBUG - 2012-11-23 15:52:58 --&gt; Config Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Hooks Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Utf8 Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; UTF-8 Support Enabled
DEBUG - 2012-11-23 15:52:58 --&gt; URI Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Router Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; No URI present. Default controller set.
DEBUG - 2012-11-23 15:52:58 --&gt; Output Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Security Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Input Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2012-11-23 15:52:58 --&gt; Language Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Loader Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; Controller Class Initialized
DEBUG - 2012-11-23 15:52:58 --&gt; File loaded: application/views/templates/header.php
DEBUG - 2012-11-23 15:52:58 --&gt; File loaded: application/views/pages/home.php
DEBUG - 2012-11-23 15:52:58 --&gt; File loaded: application/views/templates/footer.php
DEBUG - 2012-11-23 15:52:58 --&gt; Final output sent to browser
DEBUG - 2012-11-23 15:52:58 --&gt; Total execution time: 0.0168
DEBUG - 2012-11-23 15:53:11 --&gt; Config Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Hooks Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Utf8 Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; UTF-8 Support Enabled
DEBUG - 2012-11-23 15:53:11 --&gt; URI Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Router Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Output Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Security Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Input Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2012-11-23 15:53:11 --&gt; Language Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Loader Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Controller Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Model Class Initialized
DEBUG - 2012-11-23 15:53:11 --&gt; Database Driver Class Initialized
#6

[eluser]satej[/eluser]
Everything appears fine to me though from the log list. Can you give me some extra info regarding the code you have setup? I don't think the wheezy set up is the problem.
#7

[eluser]fredmanglis[/eluser]
Well, I can't seem to find anything else that is related to that... I have put my code in the 'CodeIgniter_2.1.3/application/' folder in '/var/www/', I don't know if that helps.

The code I am working on is as I have posted here (copy - paste). Also, my OS is 64-bit, therefore my daemons are mostly also 64-bit...
#8

[eluser]fredmanglis[/eluser]
Apparently, I had not installed the database modules needed to make PHP work with either mysql and postgresql.

I made an assumption they would be installed by default, as I was used to it happening in the past; apparently that has changed.

I would have given up, had I not decided to play with WordPress, which gave me informed me of the absence of the mysql module (CI, unfortunately, did not), and I also installed the postgresql module too.

Thank you for your time though.
#9

[eluser]satej[/eluser]
GreatSmile




Theme © iAndrew 2016 - Forum software by © MyBB