Str_Replace Accents in Rawurlencode

Discussion in 'PHP' started by ad9093, Nov 2, 2010.

  1. #1
    Hi again, I have another question.

    In my script, I have used search parameters for the visitor to sort table entries by.
    My urls are not browser friendly though, and I wish to use str_replace to replace some accents such as "ê" to "e", etc.

    My search parameters:
    
    $searchType='AND';
    $conquery ='';
    $conquery .= (isset($_GET['name']) && !empty($_GET['name']) ? $searchType." `brand`='" . mysql_real_escape_string($_GET['brand']) . "' " : '');
    $conquery .= (isset($_GET['color'])  && !empty($_GET['color'])  ? $searchType."  `type`='" . mysql_real_escape_string($_GET['type'])  . "' " : '');
    $conquery .= (isset($_GET['size'])  && !empty($_GET['size'])  ? $searchType."  `year`='" . mysql_real_escape_string($_GET['year'])  . "' " : '');
    
    if(trim($conquery)=="")
    {
        $query = "(select * from table_1) union (select * from table_2) union (select * from table_3) order by datetime desc ";
    }
    else
    { 
        $conquery=substr($conquery,strlen($searchType));
        $query = "(select * from table_1 WHERE $conquery) union (select * from table_2 WHERE $conquery) union (select * from table_3 WHERE $conquery) order by datetime desc ";
    }
    
    $result = mysql_query($query, $connection) or die
    ("Could not execute query : $query ." . mysql_error());
    
    PHP:
    I'm not sure, but I think the problem lies here (this is where I encode my urls) and the str_replace needs to follow this code?:
    
    $brand=rawurlencode($_GET['brand']);
    $year=rawurlencode($_GET['year']);
    $type=rawurlencode($_GET['type']);
    
    PHP:

    I've tried using a simple str_replace array but it didn't work; I think what I'm looking for is more advanced, but I don't know how to form a complex str_replace array.

    Any help is much appreciated.
     
    ad9093, Nov 2, 2010 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    i think you are over estimating here, this is not complicated. \
    where does the accent comes from? user input?
     
    bartolay13, Nov 2, 2010 IP
  3. ad9093

    ad9093 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thank you for replying.

    The accent comes from information that is in the table--- information I submitted myself.

    I am sure it is not complicated, and while I am familiar with basic php string replace, I've never had to do it with a urlencode before and though I tried several different manners, I got stuck... :(
     
    ad9093, Nov 2, 2010 IP