#!/usr/bin/perl -wT use strict; use CGI; use warnings; use 5.010; use utf8; use DBI; use Data::Dumper; # use LWP::Simple; #header my $query = CGI->new(); warn Dumper($query); print $query->header( "text/html" ), $query->start_html(-title => "Inserisci prodotti", -bgcolor => "#ddffdd" ); #definition of variables my $db="prova"; my $host="localhost"; my $user="I-inserted-here-the-user-name"; my $password="I-inserted-here-the-user-pass"; #connect to MySQL database my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database: $DBI::errstr\n"; print <<'HERE'; Prova input

Inserisci questo prodotto nel database dei negozi:





HERE print $query->end_html(); $dbh->disconnect( ); exit; #### #!/usr/bin/perl -wT use strict; use CGI; use warnings; use 5.010; use utf8; use DBI; use Data::Dumper; use LWP::Simple; #header my $query = CGI->new(); warn Dumper($query); print $query->header( "text/html" ), $query->start_html(-title => "Query prodotti", -bgcolor => "#ddffdd" ); #definition of variables my $db="prova"; my $host="localhost"; my $user="I-inserted-here-the-user-name"; my $password="I-inserted-here-the-user-pass"; #connect to MySQL database my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database: $DBI::errstr\n"; ##assign keyword to a variable #my $key_id_prod = "key_id_prod"; my $key_nome_prod = "key_nome_prod"; my $key_tipo_prod = "key_tipo_prod"; #prepare the query my $sql = "INSERT INTO prodotti (nome_prod , tipologia_prod) VALUES (? , ?)" ; my $sth = $dbh->prepare( $sql); $sth->bind_param( $key_nome_prod, $key_tipo_prod); #execute the query $sth->execute( ); # Retrieve the results of a row of data and print my ( $id_prod); $sth->bind_columns ( undef,\$id_prod, \$key_nome_prod, \$key_tipo_prod ); print "La lista aggiornata dei prodotti presenti nel database negozi è:

"; print " ===================================================================

"; while ( $sth->fetch( ) ) { print "Id del prodotto= $id_prod , il nome del prodotto è $key_nome_prod della tipologia $key_tipo_prod .
"; } print $query->end_html(); $sth->finish( ); $dbh->disconnect( ); exit; ##
## eirinyalaura@Laura://var/log$ sudo tail -f /var/log/apache2/error.log [sudo] password for eirinyalaura: [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: DBD::mysql::st bind_columns failed: Statement has no result columns to bind (perhaps you need to successfully call execute first, or again) at /usr/lib/cgi-bin/databaseLWP.cgi line 54., referer: http://localhost/cgi-bin/LWP_Query.cgi [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: DBD::mysql::st fetch failed: fetch() without execute() at /usr/lib/cgi-bin/databaseLWP.cgi line 59., referer: http://localhost/cgi-bin/LWP_Query.cgi [XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: $VAR1 = bless( { [XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: '.parameters' => [], [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: '.fieldnames' => {}, [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: 'use_tempfile' => 1, [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: '.charset' => 'ISO-8859-1', [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: 'escape' => 1, [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: 'param' => {} [Thu Dec 10 XXX] [cgi:error] [pid XXX] [client ::XXX] XXX: }, 'CGI' );