Welcome Guest, Not a member yet? Register   Sign In
html special characters & mysql
#6

[eluser]NikosV[/eluser]
ok maybe i didn't myself clear... while i retrieve data without special data codes from db.. when sending query are turning into special character codes...

let's say i have a model function get_best_resto() is like this:

Code:
function get_best_resto($startRow='',$n='')
    {
        $query = $this->db->query("select * from restaurant group by resto_rating DESC,resto_review DESC limit ".$startRow.",".$n);
        
        return $query;
    }


in the view file i am calling the above model function and i create link to a controller function restaurant/index() giving as input the resto_name :

Code:
<?php
                        $recommended_resto = $this->restaurant_model->get_best_resto(0,5);
                        
                        if($recommended_resto->num_rows()>0)
                        {
                            foreach($recommended_resto->result_array() as $row_reco)
                            {
                    ?>                
                    
                    <!-- RESTO 1-->
                    <div class="recommended_wrap">    
            
                        <div class="recommended_mid">                            
                            <p><a href="&lt;?php echo site_url('restaurant/index').">&lt;?php echo $row_reco['resto_name'];?&gt;</a></p>
                            
...                            
...


so when clicking the link the following controller function is loaded which is calling a model function is_resto_exist() to check if the keyword (resto_name) exists in the database:

Code:
function index($keyword='')
    {
            if(!empty($keyword))
        
        {    
            $is_resto_exist = $this->restaurant_model->is_resto_exist($keyword);        
                    
            
            if(isset($_SESSION['loggedin']) == 1)
            {            
                if($is_resto_exist)
                {
...

tha is_resto_exist model function is as follows:


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;
        }
    }




and here is the problem: when keyword containing special characters (parenthesis in my case) cannot find it in the database. i used the CI profiler to check why is that happening, as it is the same sting that it retrieves from the database. and i realized that while it recieves the string from the database in the form "restaurant (whatever)", in the query it sends is in the form "restaurant & #40 the & #41". The problem is only solved when saving in the database the special character codes.
so...can anyone tell me, what i am missing here? how can i solve this problem?


Messages In This Thread
html special characters & mysql - by El Forum - 03-11-2010, 05:39 PM
html special characters & mysql - by El Forum - 03-11-2010, 05:41 PM
html special characters & mysql - by El Forum - 03-11-2010, 05:59 PM
html special characters & mysql - by El Forum - 03-11-2010, 06:26 PM
html special characters & mysql - by El Forum - 03-11-2010, 09:20 PM
html special characters & mysql - by El Forum - 03-12-2010, 03:03 AM
html special characters & mysql - by El Forum - 03-12-2010, 05:55 AM
html special characters & mysql - by El Forum - 03-12-2010, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB