Welcome Guest, Not a member yet? Register   Sign In
Query string does not pass the parameter...
#1

[eluser]Peter Lachky[/eluser]
Hello everybody,

for a certain reason I have to use query_strings for one controller. It's special case of receiving data via HTTP request from another provider and I do not have the option to configure the HTTP request.

Anyway, I have enabled the query strings
Code:
$config['enable_query_strings'] = TRUE;
$config['controller_trigger']     = 'c';
$config['function_trigger']     = 'm';

and in the controller which handles this HTTP request I have this function just to check whether I am getting the request:

Code:
function topovat($id) {
        print_r($id);
    }

The name of the controler is toping.php so when I do this HTTP request

Code:
http://myweb.com/index.php?c=toping&m=topovat&id=test

I should be able to see the content of the id parameter. However, I can only see a warning saying
Quote:Missing argument 1 for Toping::topovat()
.
Now what's wrong? (And no, I haven't configured anything for this controller in routes config)

Thank you.
#2

[eluser]JHackamack[/eluser]
Have you tried removing the $id from the "topovat($id)" and doing a print_r($_GET);
#3

[eluser]Dyllon[/eluser]
Use the input class to get your ID

Code:
$id = $this->input->get('id');
#4

[eluser]laytone[/eluser]
I ran into this problem once, Here is my forum thread:

http://ellislab.com/forums/viewthread/129318/

after implementing the input class extension somebody could browse to

http://mysite.com/index.php/controller/m...l&var2=val

I was able to retrieve my variable like this

$id = $this->input->get('id');

after you fallow the instruction in the forum post above, make your function start like this:

Code:
function yourfunc($id = 0){
  $id = ($id == 0) ? $this->input->get('id') : $id;
  // The line above is the same as this:
  if ($id == 0){
   $id = $this->input->post('id');
  } else {
   $id = $id
  }
}

now you can invoke the method two ways: index.php/controller/yourfunc/1234 or index.php/controller/yourfunc/?id=1234




Theme © iAndrew 2016 - Forum software by © MyBB