The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hit the MySQL with PERL

Discussion in 'General Discussion' started by ehsan, Jul 10, 2002.

  1. ehsan

    ehsan Well-Known Member

    Joined:
    Dec 11, 2001
    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    16
    Hi,
    How do i hit database with PERL, are the modules installed by default for that or not?
    I have something like

    #!/usr/local/bin/perl
    print &Content-type: text/html\n\n&;
    print &1&;

    use CGI;
    use DBI;

    my $db = &DBI:mysql:dbname&;
    my $username = &dbuser&;
    my $pass = &dbpass&;
    my $dbh = DBI-&connect($db, $username, $pass)
    or die &Unable to connect to the Database: $dbh-&errstr\n&;
    print &2&;
    ....


    --------------
    after I run the script, it prints 1 but it does not print 2, seems like it dies somewhere ...


    Thanks,

    ~ dude
     
  2. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    well if you run the perl script and you dont get a @INC error then you have all the required modules installed.
     
  3. Site5-Matt

    Site5-Matt Well-Known Member
    PartnerNOC

    Joined:
    Aug 10, 2001
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    [quote:78d2a4c64b][i:78d2a4c64b]Originally posted by ehsan[/i:78d2a4c64b]
    ...
    or die &Unable to connect to the Database: $dbh-&errstr\n&;
    ...[/quote:78d2a4c64b]I would recommend changing $dbh-&errstr to $DBI::errstr

    Also, just to make sure, run the following command on your server:

    perl -MCPAN -e 'force install DBD::mysql'
     
  4. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    /scripts/installdbi
     
Loading...

Share This Page