Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: How to use MySQL from CGI?
by cchampion (Curate) on Feb 04, 2004 at 20:23 UTC
Re: How to use MySQL from CGI?
by matthewb (Curate) on Feb 04, 2004 at 20:29 UTC
    Can someone just give me a snippet on how to connect to a MySQL db from a website?
    #!/usr/bin/perl -T use warnings FATAL => 'all'; use strict; use DBI; use CGI; my( $dsn, $username, $password ) = qw( you tell me ); my $dbh = DBI->connect( $dsn, $username, $password ) or die DBI::errstr; my $q = CGI->new; print $q->header, $q->h1( "Looks like we connected to $dsn!" ); exit;

    You have much reading to do.

    MB
Re: How to use MySQL from CGI?
by blue_cowdawg (Monsignor) on Feb 04, 2004 at 21:07 UTC

    Let me suggest the following reading to you:

    1. Before You Post ...
    2. How (Not) To Ask A Question
    3. Before asking a database related question ...
    4. DBI recipes
    I know it isn't quite what you were asking for, but some effort on your part will help you in the long run better than my spoon-feeding you.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
Re: How to use MySQL from CGI?
by BUU (Prior) on Feb 04, 2004 at 21:50 UTC
    The only difference between a "command line" and a "cgi" script, at least for 99% of perl scripts, is you print html instead of just printing the data. It should be trivial to generalize from a command line example to a cgi example and vice versa.