in reply to Re^4: mysql error
in thread mysql error

Yeah, compare the paths in the /tmp/inc.XXX files to see how they differ. If the CGI version isn't printing the file maybe try to test the file open like:
open $fh, ">", "/tmp/inc.$$" or die "error: failed to open file=/tmp/i +nc.$$ for writing.\n";
If you know how to check if it's the CGI version you can change the file name from /tmp/inc.$$ to /tmp/inc.cgi or /tmp/inc.cl to make it easier to know which is which. But the time stamps should help with that as is.