Welcome Guest, Not a member yet? Register   Sign In
$this->uri->segment() returns FALSE [SOLVED]
#1

[eluser]Unknown[/eluser]
*************SOLVED*****************

changed uri_protocol in config file to REQUEST_URI as discussed in this thread:

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


****************SOLVED***************

I hope someone can help! I am at my wits end.

I developed an application on my local machine and there were no issues with routing at all. I have uploaded to a live site and now I am not getting any information from the URI class at all. My entire app depends on the class!!

I have used a single controller for everything by routing:

Code:
$route['default_controller'] = "hub";
$route['scaffolding_trigger'] = "";
$route[':any'] = "hub";

Within the "Hub" controller I have used the _remap() function to route everything:

Code:
function _remap($method)
{
    //function is always segment 1 as there are no other controllers
    $method = $this->uri->segment(1);    //the function
    $var1 = $this->uri->segment(2);        //the page
    $var2 = $this->uri->segment(3);        //the first var
    $var3 = $this->uri->segment(4);        //the second var
    $var4 = $this->uri->segment(5);        //thrid var
    $var5 = $this->uri->segment(6);        //fourth var
    
        
    //changing the dash to an underscore for php
    $methodOrig = $method;
    $method = url_title($method, 'underscore', TRUE);
    
    
    
    //loads all the languages available through a folder search
    $languages = $this->lingua->dirContents(APPPATH.'/language/','folder');
    //changes the dash to an underscore (language codes have dashes - functions have underscores)
    foreach ($languages as $lang){
    $lang_array[] = url_title($lang, 'underscore', TRUE);
    }
    
    $languages = $lang_array;
    
    $members = $this->common->regMembers();
    $newMemb=array();
    $this->common->array_flatten($members,$newMemb);
    $this->firephp->fb($newMemb);
    switch (true){
            //tests whether the requested url is a language rather than a function
            case (!empty($method) && in_array($method,$languages)):
            //assigns the function to segment 2 rather than 1 which is the language
            $function = $this->uri->segment(2,'index');            
            $function = url_title($function, 'underscore', TRUE);
            $this->$function($var2,$var3,$var4,$var5,'');
        break;
            //tests wether the requested url is a valid function and calls the function
            case (!empty($method) && method_exists($this, $method)):
            $this->$method($var1,$var2,$var3,$var4,$var5);        
        break;
//user function            
case (!empty($methodOrig) && in_array($methodOrig,$newMemb)):
            $this->userSurveys($methodOrig,$var1,$var2);    
            
        break;
            //if all else fails - go to the index page
            default:            
            $this->index();
        break;
    }
}

I have recently put the $method variable into the remap function brackets and when echoed, $method returns index rather than what is actually in the uri string. (index has been removed via mod_rewrite)

Every call to $this->uri->segment(#) returns FALSE.

Any ideas about what I have done wrong?? This is supposed to go live tomorrow morning!

Thanks everyone,
Sheri
#2

[eluser]derekmichaeljohnson[/eluser]
Well, I'm having a similar issue, however, I was already using REQUEST_URI and $this->uri->segment(any number) returns NOTHING.

Works fine on our local server with uri_protocol set to AUTO, but when uploading the site to Host Gator we have to change the protocol to REQUEST_URI or the site won't work.

Any help?
#3

[eluser]derekmichaeljohnson[/eluser]
Hmm.. no one?




Theme © iAndrew 2016 - Forum software by © MyBB