Welcome Guest, Not a member yet? Register   Sign In
pass a variable to controller (with nonenglish characters)
#1

[eluser]chejnik[/eluser]
Hello,
I would like to pass some variables to controller, but they contain nonEnglish characters (like æ,ð) from Icelandic alphabet.

First I make search query and I make list of headwords. Clicking on headword I would like to make detail view of headword with format. So I have to pass the headword and his number.

Code:
if($query->num_rows()>0){
                foreach($query->result() as $row){  
                       $segments = array('search', 'showHeadword', $row->keyword, $row->num_keyword );
                       $url = site_url($segments);    
                
                       $listheadwords[]= anchor($url, $row->keyword.','. $row->gram_1);
            
                }
                 }  
                $data['listheadwords'] = $listheadwords;

            
             $this->load->view('searchresults', $data);

I am not sure if I do it correctly, but I make hyperlink. The last to items in segments array are variables, right?
Thank you for help and the CodeIgniter.
Ales
#2

[eluser]Edemilson Lima[/eluser]
You must urlencode() a string with non-ASCII characters before pass it by the URI. Also you must allow the characters generated by urlencode() in your config file.
#3

[eluser]chejnik[/eluser]
Hello, thank you.

I have encoded the url with urlencode - the result is here
Code:
..search/showHeadword/sei n % C 3 % B E roska/0
I devided the urlencoded word with spaces, because it is formatted.

Code:
$string1 = urlencode($item["keyword"]);
            
        $segments = array('search', 'showHeadword', $string1, $item["num_keyword"]);
        $url = site_url($segments);

But when I click on the link / this message shows - The URI you submitted has disallowed characters.
Thank you Ales
#4

[eluser]Edemilson Lima[/eluser]
Open your config file at "system/application/config" folder and allow any extra characters not yet allowed in the regular expression:

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';




Theme © iAndrew 2016 - Forum software by © MyBB