in reply to What is the best way to validate data ?
Strings can be handled the same way by adding the quotion marks to the string variable intead of the SQL insert (enabling NULL fields to be inserted):
$string_var = "'$string_var'" if $string_var;
Of course, if the string can be null, the quotation marks need to be added before the string is verified against undef or you'll have columns with 'NULL' values instead of NULL.
To make things simple, create a function which does validation. If you need to stop on missing fields, use the code suggested by Russ.
|
|---|