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

Hi monks,

I am new to CGI programming, How to connect mysql database in CGI.

Thanks in advance.

Regards,
Gubendran.L

Replies are listed 'Best First'.
Re: CGI with mysql
by pelagic (Priest) on Jan 28, 2005 at 09:58 UTC
    use CGI; use DBI; ## ... $dbh=DBI->connect($dsn,$user,$password) or die $DBI::errstr; ## ...
    You must look into the documentation of DBI.

    pelagic
Re: CGI with mysql
by gellyfish (Monsignor) on Jan 28, 2005 at 09:56 UTC

    IN order to connect a database using the CGI you will need a gateway program that implements the CGI to perform the connection, make the required queries and return the appropriate data using the Common Gateway Interface. If you wanted to use Perl to create the gateway program you probably would want to use the module DBD::mysql to access the database.

    /J\

Re: CGI with mysql
by macPerl (Beadle) on Jan 28, 2005 at 11:03 UTC
    Also check out the perl section of the (downloadable) MySQL reference manual. I found it a very succinct "how to".
Re: CGI with mysql
by b10m (Vicar) on Jan 28, 2005 at 10:46 UTC

    You've gotten the right direction by others (to look at DBI), but you might also want to look into Class::DBI which you will love once you get it to work a little.

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: CGI with mysql
by kelan (Deacon) on Jan 28, 2005 at 14:21 UTC

    If you are new to CGI, you should have a look at Ovid's CGI course. It is very nice for the CGI beginner.

Re: CGI with mysql
by bradcathey (Prior) on Jan 28, 2005 at 16:16 UTC

    gube, These books aren't too popular around here, and, in most cases, for good reason. However, I found this one particular thorough and well written: Larry Ullman's MySQL in the Visual Quickstart series. It will give you a nice overview and a springboard into the more complex resources. Thought I should point it out.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot