O $this->db->escape($url) já coloca os ' ' para você...

O Certo fica assim:

function check_url_exists_in_db($url)
{
  $query = $this->db->query("SELECT * FROM nws_news WHERE
url=".$this->db->escape($url)." AND active='1'");
  $this->db->query($query);
  if ($this->db->affected_rows() >= 1)
  {
    return true;
  }
  else
  {
    return false;
  }
}


Andrey


2008/11/4 Cleyverson Costa <[EMAIL PROTECTED]>

> Pesoal, o que existe de errado nesta função??
>
>     function check_url_exists_in_db($url) {
>         $query = $this->db->query("SELECT * FROM nws_news WHERE
> url='".$this->db->escape($url)."' AND active='1'");
>         $this->db->query($query);
>         if ($this->db->affected_rows() >= 1) {
>             return true;
>         }
>         else {
>             return false;
>         }
>     }
>
> --
>
> A Database Error Occurred
>
> Error Number: 1064
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near '
> http://noticias.uol.com.br/ultnot/efe/2008/08/26/ult1808u125085.jhtm'' AND
> activ' at line 1
>
> SELECT * FROM nws_news WHERE url=''
> http://noticias.uol.com.br/ultnot/efe/2008/08/26/ult1808u125085.jhtm'' AND
> active='1'
>
>
> _______________________________________________
> Lista mailing list
> [email protected]
> http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br
>
>
_______________________________________________
Lista mailing list
[email protected]
http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br

Responder a