in reply to Re^2: SQL error
in thread SQL error

Just what it seemed, close the quote in $stg = $dbh->prepare('SELECT REFERENCE, REQUIREMENTS FROM TestCasesOutput WHERE PassFail = "fail";

Should be:

$stg = $dbh->prepare('SELECT REFERENCE, REQUIREMENTS FROM TestCasesOutput WHERE PassFail = "fail"');

BTW, try reading Writeups Formatting Tips and How do I post a question effectively?, they can help you a lot.

deibyz