Fixed var sql to query.
[reportero_perl.git] / reportero
blob4a6852897c80af251d8e1376df80ec1150bf170e
1 #!/bin/env perl
2 # Test reporting program
4 use warnings;
5 use DBI;
6 use CGI qw(:standard);
7 use CGI::Carp qw(fatalsToBrowser);
10 $db_name = "tarificador";
11 $db_user = "tarificador";
12 $db_passwd = "n3ur0d3s4rr0ll008";
14 sub
15 db_search
17   my $dbh = shift ;
18   my $sql = param('query');
20   warn "SQL = $sql;\n";
22   my $sth = $dbh->prepare("$sql");
23   $sth->execute()
24     or print "I cannot execute $sql";
26   print <<'  END'
27     <html>
28     <head></head>
29     <body>
30   END
31   ;
33   my $count;
34   while (my $hash = $sth->fetchrow_hashref)
35   {
36     print 
37       "$hash->{id},$hash->{fecha_hora},$hash->{origen},$hash->{destino}<br/>";
38     print "TEST";
39     $count++;
40   }
42   print <<'  END'
43     </body>
44     </html>
45   END
46   ;
49 my $dbh = DBI->connect("dbi:mysql:dbname=$db_name"
50     , "$db_user", "$db_passwd")
51     or die "ERROR: Cannot connect to DB: $DBI::errstr!\n";
53 print header();
55 db_search($dbh);