Welcome Guest, Not a member yet? Register   Sign In
URI Segment problem
#1

[eluser]sohei[/eluser]
Hi everybody,
I simply want to get an id by the url.

Here's my function in my controller called "stock":
Code:
function delete_single_item($iditem) {
      echo $iditem;
}

And when I go here:
http://localhost/mywebsite/stock/delete_single_item/167

I get this error:
Quote:"Missing argument 1 for Stock::delete_single_item()"


Can anyone tell me why ? It looks so simple and it doesn't work...
#2

[eluser]sohei[/eluser]
Please help me Sad(
#3

[eluser]LuckyFella73[/eluser]
Are you using URI Routing? Usually it should work
like you tried to (reading the user guide).
I use to get the uri parameters using the URI function
Code:
$this->uri->segment(n)
// or
$this->uri->rsegment(n)
In your case it should look like:
Code:
function delete_single_item() {
      $iditem = $this->uri->segment(3)
echo $iditem;
}

Should work ..
#4

[eluser]sohei[/eluser]
[quote author="LuckyFella73" date="1292804697"]Are you using URI Routing? Usually it should work
like you tried to (reading the user guide).
I use to get the uri parameters using the URI function
Code:
$this->uri->segment(n)
// or
$this->uri->rsegment(n)
In your case it should look like:
Code:
function delete_single_item() {
      $iditem = $this->uri->segment(3)
echo $iditem;
}

Should work ..[/quote]

Nope, the only routing rules I have is the default
Code:
$route['default_controller'] = "home";
$route['scaffolding_trigger'] = "";

And when I try this with http://localhost/mywebsite/stock/delete_single_item/168:
Code:
function delete_single_item() {
            echo $this->uri->segment(3);
        }

It return nothing..

I really don't see what's wrong Sad


EDIT: Could it come from my URL Rewriting? (used to remove index.php)
#5

[eluser]sohei[/eluser]
It's okay,
I don't know why but I had autoload the uri:
Code:
$autoload['libraries'] = array('database','uri');

Now I have remove it and it works.
Thank you anyway LuckyFella.
#6

[eluser]LuckyFella73[/eluser]
I found it strange too that it didn't work from the
beginning..
It still strange because according to the user guide
the uri class is loaded by default...




Theme © iAndrew 2016 - Forum software by © MyBB