If you're using PHP:
mysql_escape_string()
Further data sanitisation is probably a good idea, eg if a variable should be numeric only force it to be that by doing something like
$var = 0 + $_GET["id"] . If someone enters "15; DROP DATABASE blah" then $var will only contain 15.