Your webserver error log should give you more hints as to what is wrong (error_log if you are running Apache by the way). Does the script run properly from the command line? Does
$cols exist and contain what you think it should contain? Perhaps you should read some of the posts under
CGI Programming from the
tutorials section of this site.
Martin