不是/转义符,是一个ad什么的词,怎么包这句SQL
$where = "where 1";
  if(!empty($ziduan) && !empty($txt_sousuo))
  {
    $where .= " and $ziduan like '%{$txt_sousuo}%'"; 
  }
$sql = "SELECT count(h_id) as countnum FROM hotel_activities_2 $where ";

解决方案 »

  1.   

    主要是这句话
    $where .= " and $ziduan like '%{$txt_sousuo}%'"; 
      

  2.   

    这样么$where = "where 1";
      if(!empty($ziduan) && !empty($txt_sousuo))
      {
        $where .= " and $ziduan like '%{$txt_sousuo}%'"; 
      }
    addslashes($sql) = "SELECT count(h_id) as countnum FROM hotel_activities_2 $where ";
    $result = mysql_query($sql);
      

  3.   

    $where = "where 1";
    $where=addslashes($where);
      if(!empty($ziduan) && !empty($txt_sousuo))
      {
        $where .= " and $ziduan like '%{$txt_sousuo}%'"; 
      }
      
    $sql = "SELECT count(h_id) as countnum FROM hotel_activities_2 $where ";
    $result = mysql_query($sql);
    这样么
      

  4.   

    这样比较好。
    $where = "where 1";
    if(!empty($ziduan) && !empty($txt_sousuo)){
        $where .= " and $ziduan like '%{$txt_sousuo}%'"; 
    }
    $sql = mysql_real_escape_string("SELECT count(h_id) as countnum FROM hotel_activities_2 $where ");
    $result = mysql_query($sql);