Welcome Guest, Not a member yet? Register   Sign In
wrong action method called
#1

[eluser]welzie[/eluser]
I am testing CI 1.6.0 on my godaddy hosting account. I have followed instructions here for setup: http://codeigniter.com/wiki/Godaddy_Installaton_Tips/.

I am getting weird results from my simple tests. Please help.

Here are my test urls and the result shown in the browser:
url -> http://mydomain.org/codeIgniter/index.php?
result -> CodeIgniter Welcome Page

url -> http://mydomain.org/codeIgniter/welcome
result -> CodeIgniter Welcome Page

url -> http://mydomain.org/codeIgniter/blog/view/
result -> 404 Page Not Found

url -> http://mydomain.org/codeIgniter/blog/
result -> "hello world" (Why isn't the index method called???)

Here is my blog contoller (in the contollers folder)
Code:
class Blog extends Controller {

    function index()
    {
        $data['entries'] = array( 'entry1','entry2','entry3');
        $this->load->view('blogview', $data);
    }
    
    function view() {
        echo "hello world";
    }
}

blogview.php (in the views folder)
Code:
<html>
<head>
<title>My Blog</title>
</head>
<body>
    <h1>Welcome to my Blog!</h1>
    <ul>
        &lt;?php foreach($entries as $entry):?&gt;
            <li>&lt;?php echo $entry;?&gt;</li>
        &lt;?php endforeach;?&gt;
    </ul>
&lt;/body&gt;
&lt;/html&gt;

P.S. If I take the "view" method out of the controller. The blogview.php is displayed normally with this url http://mydomain.org/codeIgniter/blog/
#2

[eluser]ontguy[/eluser]
Seems odd.

If a simple echo is put in the "index" method with the "view" method, does this work?
#3

[eluser]wiredesignz[/eluser]
Have you added parent::Controller() in your blog controller constructor?
#4

[eluser]welzie[/eluser]
Had to force my web host to use php5, godaddy uses php4 by default. I did it by adding these lines to my .htaccess file. Found that info at this link: http://help.godaddy.com/article/1082

Code:
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

@wiredesignz, Thx for pointing me to a php version issue. Your post reminded me that calls to parent::constructors are not done by default in php4.




Theme © iAndrew 2016 - Forum software by © MyBB