I'm working on a small counter script that will allow me to count page hits without SSI. I call the following code using the <script> tag with a source being the cgi script that will count for me. The problem I'm having is that it doesn't seem to run the script at all when called on page load and it doesn't seem to return errors. Where am I going wrong here? I've checked the SQL and it executes fine if I replace the $name variable with some text.
HTML File: <script type="text/javascript" src="/cgi-bin/thecount/thecount.cgi?name=test"></script> CGI File: #perl.exe #<-- insert your favorite bash here use strict; use DBI; use CGI qw/ :cgi /; #Cookie parameters. my $cpre = "WEC_count_"; my $path = "/cgi-bin/thecount"; #Initialize a few useful vars. my $name = param('name'); my $cookie = cookie( "$cpre$name" ); #Unless the cookie exists, we need to add to the count. unless ( $cookie ) { my $dbi = DBI->connect( "DBI:mysql:counter", "counter", "" ) || die; my $sql = "SELECT count, created FROM thecount WHERE name=$name"; my $sth = $dbi->prepare( $sql );$sth->execute || die; #If it exists increment the counter. if ( $sth->rows ) { $dbi->do( "UPDATE thecount SET count=count + 1 WHERE name='$name'" ) || die } #If the name isn't in the database, it's new. else { $dbi->do( "INSERT INTO thecount SET name='$name', created=NOW(), count=1" ) || die } } #Set the cookie to expire in 1 day, and send it to the user. $cookie = cookie( -name=>"$cpre$name", -value=>1, -path=>$path, -expires=>"+1d" ); print header( -type=>'application/x-javascript', -cookie=>[$cookie] ); exit; -------------------------------------------- Scott Anderson WeekendClimber.Com [EMAIL PROTECTED] http://www.weekendclimber.com _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs