Welcome Guest, Not a member yet? Register   Sign In
URLENCODE doesn't work
#1

[eluser]Ludatha[/eluser]
For some reason urlencode doesn't work with my codeigniter, a have a script that encodes titles of forum threads so they can be used in the URL, but urlencode is not encoding :O

http://ludatha.com/forum/category/Spam Land.html

If you go to that website and click one of the threads that have special characters in them, it will say 404 not found, or Disallowed Key Characters...

The function urlencode does work on my server as I made a test script to test it
http://ludatha.com/test/testencode.php
It encodes fine

So here comes my code

Function:createURI
Code:
function createURI($id, $string, $place, $total = TRUE){
        $string = str_replace(' ', '_', $string);
        /*
        $string = str_replace('!', '', $string);
        $string = str_replace('?', '', $string);
        $string = str_replace(':', '', $string);
        $string = str_replace(']', '', $string);
        $string = str_replace('[', '', $string);
        $string = str_replace('"', '', $string);
        $string = str_replace('£', '', $string);
        $string = str_replace('$', '', $string);
        $string = str_replace('%', '', $string);
        $string = str_replace('^', '', $string);
        $string = str_replace('&', '', $string);
        $string = str_replace('*', '', $string);
        $string = str_replace('(', '', $string);
        $string = str_replace(')', '', $string);
        $string = str_replace('-', '', $string);
        $string = str_replace('#', '', $string);
        $string = str_replace('~', '', $string);
        $string = str_replace(';', '', $string);
        $string = str_replace('\'', '', $string);
        $string = str_replace('/', '', $string);
        */
        $string = urlencode($string);
        
        if($place == 'forum'){
            $url = 'forum/post/';
        }elseif($place == 'portal'){
            $url = 'portal/view/';
        }elseif($place == 'arcade'){
        $url = 'arcade/play/';
        }else{
            $url = '';
        }
        
        if($total){
            return base_url() .$url . $id . '-' . $string . '.html';
        }else{
            return $id . '-' . $string;
        }
    }

This is the code used to get the latest thread
Code:
$latestThread = $latestPostRow->name;
                        $latestThread = $this->db->escape_str($latestThread);
                        $url = $this->ludatha->createURI($latestPostRow->id, $latestThread, 'forum');
                        $lastPostContent = 'Last thread by <a >owner.'.html">'.$latestPostRow->owner.'</a><br />
                          in <a href="'.$url.'">'.$latestPostRow->name.'</a><br />
                          at '.$latestPostRow->postDate;

Can anyone help?


Messages In This Thread
URLENCODE doesn't work - by El Forum - 09-25-2009, 07:24 PM
URLENCODE doesn't work - by El Forum - 09-25-2009, 08:18 PM
URLENCODE doesn't work - by El Forum - 09-26-2009, 05:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB