CodeIgniter Forums
Not seeing function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Not seeing function (/showthread.php?tid=9200)



Not seeing function - El Forum - 06-16-2008

[eluser]Chris Williams[/eluser]
This works just fine on my server, but my ISP gives me a 404.

Here's what I'm using currently:
Code:
<?php
class Image extends Controller {
    function Image()
    {
        parent::Controller();
        $this->load->helper('url');
    }
    function index()
    {
        $a = $this->uri->segment(3);
        $b = $this->uri->segment(4);
        echo $a;
        echo $b;
    }
    function view()
    {
        $a = $this->uri->segment(3);
        $b = $this->uri->segment(4);
        echo $a;
        echo $b;
    }
}

Index and view are the same functions just for testing purposes.

This url works:
/index.php/image/index/2/f

but this one doesn't:
/index.php/image/view/2/f

In my log file, it says "404 Page Not Found --> image/view"

My would this work on my machine and not on my website?


Not seeing function - El Forum - 06-16-2008

[eluser]mglinski[/eluser]
Try adding the url arguments into the functions for better readability and less code:
Code:
<?php
class Image extends Controller {
    function Image()
    {
        parent::Controller();
        $this->load->helper('url');
    }
    function index($a, $b)
    {
        echo $a.$b;
    }
    function view($a,$b)
    {
        echo $a.$b;
    }
}

Might fix the issue as well.


Not seeing function - El Forum - 06-17-2008

[eluser]Chris Williams[/eluser]
The code I'm showing is just for testing. The original called a model and view for other purposes. However, neither versions work anyway. I still get a 404 error generated from CI.


Not seeing function - El Forum - 06-17-2008

[eluser]mglinski[/eluser]
Then there some missing information.
Can you post your folder structure of the application folder?
-Matt


Not seeing function - El Forum - 06-17-2008

[eluser]Chris Williams[/eluser]
Hi Matt.

I don't think it's anything to do with the contents of application folder. I've gone as far as uploading the default CI package and then adding this controller to the directory. I think there is a difference between this website and my home server for the log file to output that it can't find the file "image/view".


Not seeing function - El Forum - 06-17-2008

[eluser]xwero[/eluser]
view is a reserved name in php4


Not seeing function - El Forum - 06-17-2008

[eluser]Chris Williams[/eluser]
Whereas I'm running php5 at home. Nice find!


Not seeing function - El Forum - 06-17-2008

[eluser]xwero[/eluser]
Always check reserved names, i have had many headaches because of it but i learned my lesson Smile


Not seeing function - El Forum - 06-17-2008

[eluser]Chris Williams[/eluser]
Ya, I just verified it with phpinfo() and sure enough, my ISP gave me the wrong version. Sure enough, as well, changing the function name works like a charm.