Originally posted by ahundiak
Can you provide a link between not using majic quotes and injection attacks? I don't really see the connection. I personally think that majic quotes (which are not part of standard sql) are a bad idea and I don't use them.I don't think I'm insane but who really knows?
Ummmm. magic quotes have NOTHING to do with the SQL standard, they're a PHP feature.
Quoting, and quote escaping however, ARE part of the SQL standard, another part MySQL only gets about half right but that's another discussion for another time.
Anyway, in order to insert the string:
My cat's claws need trimming
you'd HAVE to escape the ' in the string, as the ' character in SQL spec is the quote that goes around string literals, and the way you escape a ' is with a leading \ (backslash) so you'd get:
My cat\'s claws need trimming
to insert. If you actually tried to insert the first string without escaping you'd get a sql query that would look like this:
insert into table (field1) values ('My cat's claws need trimming');
which should generate a parse error at the s right after the second ' mark.