
August 20th, 2003, 08:32 AM
|
 |
May contain nuts.
|
|
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
|
|
There aren't any real "problem characters", per se. The issues that arise when using SQL occur because of the syntax used to insert/update string values. That is (for those that don't already know  ), single quotes are needed around strings. Obviously then, if you attempt to insert a string containing a single quote, the SQL engine will assume that when it hits your single quote, this signifies the end of the string. To get around this, simply perform a replace function on any string you wish to insert in the db, replacing single quotes with 2 single quotes (not double quotes). This same logic also applies when using the ';' after a single quote, signifing the end of the SQL statement.
To write your own string validator shouldn't be too much of a problem. You should be able to do it in only a few lines (read: 1  ). Write this handler as a function (or class), that can be reused in all your future applications.
|