Welcome Guest, Not a member yet? Register   Sign In
Strange problem with $this->load->view

Hi to all!
Here my routes.php:
$route['articles/:num'] = "articles/index";
$route['articles/:num/:num'] = "articles/index";

$route['files/:num'] = "files/index";
$route['files/:num/:num'] = "files/index";

Here is my test site based on CI 1.5.4: http://z-nsk.ru/ci/

URL http://z-nsk.ru/ci/files/3 works good. It loads controller "files" which gets data from DB.
But http://z-nsk.ru/ci/articles/<number&gt; doesn't work correctly - it redirects to home page. I have found that all code in "articles" controller works correctly till string
$this->load->view('articles', $data);
It redirects browser O_o
If I changes it to
echo "blah-blah";
$this->load->view('articles', $data);
it says
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/z-nsk.ru/httpdocs/ci/system/application/controllers/articles.php:64)

Filename: helpers/url_helper.php

Line Number: 455
I can't understand WHY? If I changes this piece of code to
$this->load->_ci_load(array('view' => 'articles', 'vars' => $this->load->_ci_object_to_array($data), 'return' => false));
it works good!

Can somebody explain this mysticism?

And else: URL http://z-nsk.ru/ci/articles/view/<number&gt; doesn't work anyway.

And all of these problems didn't appear at localhost.

Server: CentOS, Apache 2.0.52, PHP 4.3.9
Localhost: Windows XP, Apache 1.3.33, PHP 5.1.6

Well, I just have changed PHP on localhost to 4.4.2 from 5.1.6 and these troubles appeared.
Now I know, that this is a problem of PHP 4.

If I change code of view() method to
echo "blah-blah";
//return $this->_ci_load(array('view' => $view, 'vars' => $this->_ci_object_to_array($vars), 'return' => $return));
it redirects to home page anyway. I can't understand why redirect() method is called.

I'm guessing it has to do with the code in the view file where you use a url helper method. As you can see the error is generated from that file.

But there are not redirect() calls in the view file articles.php. And I can change "articles" in $this->load->view() to "footer". footer.php has pure HTML. But result will be the same: redirecting to home page. Sad


[eluser]Michael Wales[/eluser]
Then it has to do something with your routing or are you using caching?

No, I don't use caching.

[eluser]Michael Wales[/eluser]
Paste your routing.

[quote author="walesmd" date="1196294103"]Paste your routing.[/quote]
It is in my first post.
Quote:RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Theme © iAndrew 2016 - Forum software by © MyBB