renzo rizzato wrote: > Hallo to all, > I am trying to access my MySQL database using the following PERL > script: > > use DBI; > use CGI qw(:standard);
You should ALWAYS "use strict", and probably "use warnings" as well. > > print "Content-type: text/html\n\n"; > > print "<HTML>\n<HEAD>\n<BODY>\n</HEAD>"; Bad HTML. You start the BODY tag inside the HEAD tag. Since you've included the CGI module, why not use it? print header, start_html; > > 1 $host = "xxx.xxx.xxx.xxx"; > 2 $database = "my_db_name"; > 3 $user = "my_user_name"; > 4 $password = "my_db_passwd"; > > 5 $dbh = DBI -> connect ("DBI:mysql:host= $host; database = > $database", $user,password); Where's your error checking? You should enable RaiseError at least. > > 6 $sth = $dbh -> prepare ("select name, wins, losses from teams"); > > 7 $sth -> execute(); > > 8 while (@val = $sth -> fetchrow_array ()) { > 9 print p (sprintf ("name = $s, wins = $d, losses = > $d\n", $val[0], $val[1], $val[2])); > 10 ++$count; } > > 11 $sth -> finish(); > 12 $dbh -> disconnect; > > print "</P></FONT></BODY>\n</HTML>"; Why are you closing P and FONT tags never opened? > > > all I get from this is a white web page , the word "done" at > page-foot. I suspect that connection has never occoured, also because > I tryed to modify the parameters making them totally wrong, aspecting > an error message telling me a "kick-off bloody foreigner!" Error messages will be in your web server's error log, so go find that. > Same applies if I put a comment char # at lines 8,9,10 > Could anyone help me? I am only a beginner and I realyze that books > do not say everything...., the script has been copied from a book > about MySQL and Perl. Not a good book. What's the name of it? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>