Anyone have a chance to look at this? -------------------------------------------- Scott Anderson BTS/Compupay [EMAIL PROTECTED] 206-242-7088 xt231
> -----Original Message----- > From: Scott Anderson (PayRight) [mailto:[EMAIL PROTECTED]] > Sent: Monday, September 30, 2002 8:22 AM > To: [EMAIL PROTECTED] > Subject: [wdvltalk] Calling a cgi script from <script src=""> > > > 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; > > > ____ � The WDVL Discussion List from WDVL.COM � ____ > To Join wdvltalk, Send An Email To: > mailto:[EMAIL PROTECTED] > Send Your Posts > To: [EMAIL PROTECTED] > To change subscription settings to the wdvltalk digest version: > http://wdvl.internet.com/WDVL/Forum/#sub > > ________________ http://www.wdvl.com _______________________ > > You are currently subscribed to wdvltalk as: > [EMAIL PROTECTED] To unsubscribe send a blank email > to %%email.unsub%% > ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: archive@jab.org To unsubscribe send a blank email to [EMAIL PROTECTED]
