SQL injection attacks involve inserting malicious SQL statements into user input on a web form to manipulate the database. For example, a search term like "blah' OR 'x'='x" could return the entire database table instead of just search results. Without proper input validation and output encoding, an attacker could delete database tables or obtain sensitive data. Developers can prevent SQL injection by escaping special characters, validating input syntax, limiting database permissions, and using bound parameters instead of concatenating user input into queries.