[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="<?php echo site_url('restaurant/index')."><?php echo $row_reco['resto_name'];?></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?