Welcome Guest, Not a member yet? Register   Sign In
my query doesn't like parenthesis!
#1

[eluser]NikosV[/eluser]
Ok, here is a function that informs me if a restaurant exists in the database. It works fine with normal names. The problem comes when there is a name which includes parenthesis such us: restaurant(the) . It cannot find it. Any solutions?

Code:
function is_resto_exist($resto_name)
    {
        $this->db->where('resto_name',$resto_name);
        
        $query = $this->db->get('restaurant');
        
        if($query->num_rows() > 0)
        {
            return true;
        }else{
            return false;
        }
    }
#2

[eluser]DisturbedMind[/eluser]
Have you checked the value in your database to verify that the restaurant name still contains the parenthesis? If you are using the xss_clean function for validation or have it enabled globally, it should be escaping the parenthesis.
#3

[eluser]danmontgomery[/eluser]
Have you enabled the profiler to see the query being run?
#4

[eluser]NikosV[/eluser]
checked the value in the database and it still contains parenthesis.
xss_clean function is globally disabled.

i guess i found the problem by enabling the profiler but i dont know how to solve it. the parenthesis is translated during the query into this sequence of chars & # 4 0 ; & # 4 1 ; (i leave spaces on purpose cause the sequence is translated into parenthesis in this forum) that for some reason mysql does not understand. i am using unicode in my database.

any help?
#5

[eluser]wonjun[/eluser]
I also ran into this today,

the parenthesis is translated during the query into this sequence of chars & # 4 0 ; & # 4 1 ;


any ideas why???

THank you.
#6

[eluser]NikosV[/eluser]
Hello there wonjun,

I am the guy who initially faced this problem and i managed to solve it by using html_entity_decode().
Just get the string through html_entity_decode() before making the query (e.g. html_entity_decode($string)).
I guess this problem occurs due to the fact that the string is passed to the function through the URI.
#7

[eluser]wonjun[/eluser]
Thank you so much, THat works great,

THank you for taking the time to let me know! I hope I can return the favor some day.




Theme © iAndrew 2016 - Forum software by © MyBB