• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not seeing function

#1
[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?

#2
[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.

#3
[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.

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

#5
[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".

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

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

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

#9
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.