Código PHP:
public function query($sql) {
$sql = $this->security($sql);
$this->consulta = mysql_query($sql, $this->link);
$this->result();
}
protected function result() {
if(is_resource($this->consulta)) {
while ($this->fila = mysql_fetch_array($this->consulta, MYSQL_ASSOC)) {
$this->salida[] = $this->fila;
}
}
}
public function security($string) {
$string = strip_tags($string);
$string = htmlentities($string, ENT_QUOTES, "UTF-8");
$string = mysql_real_escape_string($string);
return $string;
}
si llamo a la consulta del query de esta forma y con esta cadena
Código PHP:
echo $mysql->query("INSERT INTO staff (nombre) VALUES ('<script>alert();</script>')") or die(mysql_error());
Código PHP:
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 ''alert();')' at line 1
Código PHP:
echo $mysql->security("INSERT INTO staff (nombre) VALUES ('<script>alert();</script>')");
Código PHP:
INSERT INTO staff (nombre) VALUES ('alert();')
de antemano gracias
saludos