CodeIgniter Forums
URI class fails - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: URI class fails (/showthread.php?tid=24460)



URI class fails - El Forum - 11-10-2009

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


URI class fails - El Forum - 11-10-2009

[eluser]BrianDHall[/eluser]
If its an error then you haven't loaded the helper: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.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.


URI class fails - El Forum - 11-10-2009

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


URI class fails - El Forum - 11-11-2009

[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!