Welcome Guest, Not a member yet? Register   Sign In
CI does not process GET variables online
#1

[eluser]herrmoinsen[/eluser]
Hi all,

I uploaded my website I've created with CI and nearly everything is working fine.
But there is a little problem: CI does not process variables which are passed to CI via URL.

If I call a function like
Code:
controller/function/123
the 123 is not passed to the function and throws a warning:
Quote:Missing argument 1 for ...
.

Any suggestions?

Thanks
herrmoinsen
#2

[eluser]majidmx[/eluser]
Hey Herrmoinsen,
Can you post your function's body too?

Thanks,
MajiD
#3

[eluser]herrmoinsen[/eluser]
Hi MajiD,

sure I can, but it doesn't depend on the function the variable I passed to. The error occurs no matter which function is called.

But to give you an example, these two functions cause errors:

Code:
function show($id) {
        $query = $this->db->get_where ('hmp_galleries', array('ID' => $id));
        $result = $query->row_array ();
        $data = array ('page_title' => $result["title"], 'page_cat' => 'albums', 'id' => $id);
        $this->load->view('albums/show', $data);
    }

Code:
function photo ($photo_id) {
        if (!is_numeric ($photo_id)) {
            redirect ('albums');
        } else {
            $res = mysql_query ("SELECT DISTINCT g.title AS `gTitle`, g.ID AS `gID` FROM `hmp_galleries` `g`
                                    JOIN `hmp_img_images` `i` ON i.gallery = g.ID
                                    WHERE i.ID = '$photo_id'");
            $album = mysql_fetch_array ($res);
            $data = array ('page_title' => $album["gTitle"], 'page_cat' => 'albums', 'photo_id' => $photo_id, 'album_id' => $album["gID"]);
            $this->load->view ('albums/photo', $data);            
        }
    }

Both in the controller Albums.



Cheers
herrmoinsen
#4

[eluser]majidmx[/eluser]
And you call your functions like this, right ?
Code:
www.site.com/index.php/Albums/photo/12

Is your server windows ?

try this :

Code:
www.site.com/index.php/albums/photo/12

just the lowercase version of the controller name.

Let me know if it worked,

MajiD Fatemian
#5

[eluser]herrmoinsen[/eluser]
Hi,

my local server os is Mac OS X, everything is fine there. e.g:
Code:
http://localhost/2008/codeigniter/hmp/index.php/albums/show/5

After uploading my project to a linux server and calling (e.g.) this URL
Code:
http://www.myproject.de/index.php/albums/show/5

the variable is no longer passed to the function.

Thanks
herrmoinsen
#6

[eluser]majidmx[/eluser]
even if you setup a simple test controller it won't work?

Are you using any mod_rewrite on your server ?
#7

[eluser]herrmoinsen[/eluser]
I just set up this controller

Code:
<?php

class Simple extends Controller {

    
    function test($var) {
        echo $var;
    }
    
    
}

which should be the simplest.

If I call this function on my local system like

Code:
http://localhost/2008/codeigniter/hmp/index.php/simple/test/123
it works fine but online - again - I got an error message, saying there is an argument missing.

I got no mod_rewrite on the server online, because it just won't work. That's why I'm using this ugly URLs there and switched my local system to no using mod_rewrite to eliminate errors caused by this.

I'm frustrated ...
#8

[eluser]Santiago Dimattía[/eluser]
I don't know if it's possible in other way, but in "Create a Blog in 20 Minutes" Derek Jones use:
Code:
$this->uri->segment(x)

So..
Code:
function show() {
        $id = $this->uri->segment(3);
        $query = $this->db->get_where ('hmp_galleries', array('ID' => $id));
        $result = $query->row_array ();
        $data = array ('page_title' => $result["title"], 'page_cat' => 'albums', 'id' => $id);
        $this->load->view('albums/show', $data);
    }

Note: I'm new to CI (I'm learning)
Note 2: My english sucks, I know.
Note 3: You need to load URL helper.
#9

[eluser]majidmx[/eluser]
I guess server cut some parts of the URL while passing it to the Controller,
Can you try the Simple class again but having the received address printed:

Code:
<?php

class Simple extends Controller {

    function Simple(){
        parent::Controller();
    }
    
    function test($var = 'SAMPLE') {
        echo $var;
        echo    '<br/>';
        echo    $_SERVER['PHP_SELF'] . '<br/>';
        echo    $_SERVER['REQUEST_URI'] . '<br/>';
        
    }    
}
?&gt;
Note :Just made a default value for the argument to prevent the error from stop parsing the page.
Also
Code:
$this->uri->segment(x)
could be a good test to make sure everything is fine.




Theme © iAndrew 2016 - Forum software by © MyBB