Resultado html: Resultado
exemplo de código Perl acessando MySQL
Linux na web /Como armazenar informação?/SQL/MySQL./CGI-script com SQL/
#!/usr/bin/perl -w use CGI qw/:standard/; use DBI; # use DB_File; use Fcntl ; $driver = "mysql"; $database = 'mono'; $hostname = 'localhost'; # $port = ""; # nao sei e parece ser opcional $dsn = "DBI:$driver:database=$database;host=$hostname"; $user = "root"; $password = "123"; $dbh = DBI->connect($dsn, $user, $password)|| die "Got error: '$DBI::errstr' when connecting to MySQL"; # $drh = DBI->install_driver("mysql"); DBI->install_driver("mysql"); my $sth = $dbh->prepare("select * from bidic limit 10"); $sth->execute or die "$DBI::errstr"; print header, start_html('Inscrição no ViaLinuxis'), h1("resultado de um select"); while ( @row = $sth->fetchrow_array ) { foreach $palavra (@row) { print $palavra . " "; } print "<br>\n"; }; $sth->finish; $dbh->disconnect; print end_html;

  • Resultado

  • Resultado html: Resultado

    autor: Jorge Kinoshita