$agent = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); $sql = "INSERT INTO `table` set useragent = '$agent'"; $res = mysql_query($sql) or trigger_error(mysql_query.$sql);