Welcome Guest, Not a member yet? Register   Sign In
URI class fails
#1

[eluser]ivo_shandor[/eluser]
I'm a bit of a Codeigniter noob so forgive the question if it's a bit dumb...

I'm trying to use the URI class but I get nothing from functions such as base_url() or $this->uri->uri_string().

However "echo $_SERVER[@REQUEST_URI];" does work. I'm using Wampserver on WinXP. Does anyone have any ideas?
#2

[eluser]BrianDHall[/eluser]
If its an error then you haven't loaded the helper: http://ellislab.com/codeigniter/user-gui...elper.html

Quote:Loading this Helper

This helper is loaded using the following code:

$this->load->helper('url');

If that isn't the problem you'll need to be a bit more specific as to how the functions don't work. If their output is wrong check your config.php settings.
#3

[eluser]ivo_shandor[/eluser]
Thanks Brian. I've definitely loaded the helper so that's not the problem. Since my previous post I've tried changing the URI_PROTOCOL settings in the config.php file and the best outcome has been with the PATH_INFO setting. Now base_url() and a couple of other functions have begun working but I have problems with uri_string() and others.

To illustrate my problem, I have created a view with the following commands:
Code:
<?php echo(current_url()); ?> // produces 'http://localhost/ci/index.php'
<?php echo($this->uri->segment(1)); ?> // produces no output at all
<?php echo $_SERVER['PATH_INFO']; ?> // produces '/agent/profile/1'

All this is given in the view with "http://localhost/ci/index.php/agent/profile/1" in the browser address bar. As you can see uri->segment(n) doesn't seem to be working and the current_url seems to be wrong.

I hope this is clear enough. I've spent several hours looking at this and my brain feels fried...
#4

[eluser]ivo_shandor[/eluser]
Managed to fix it with one or more of the following steps. First, I switched to xampp, then I went about trying different URI_PROTOCOLS and I also deleted a call to load the URI class that was lying around in one of my other controllers - it's loaded by default anyway and I believe that was causing the problem. Thanks for you help though!




Theme © iAndrew 2016 - Forum software by © MyBB