quarta-feira, 10 de fevereiro de 2010

Trabalhar com escape com PHP e Mysql

Escape String

Escapes a string for use in a mysql_query.
    $item = "Laptop";
    $escaped_item = mysql_escape_string($item);
    printf ("Escaped string: %s\n", $escaped_item);
?>

Escape special characters in a string for use in a SQL statement, taking into account the current charset of the connection.
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$item = "Laptop";
$escaped_item = mysql_real_escape_string($item);
printf ("Escaped string: %s\n", $escaped_item);
?>

Nenhum comentário:

Postar um comentário