Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13

Thread: perl and MYSQL

  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    perl and MYSQL

    From the beginning. My website host is Hypermart.I am trying to install a classifieds script with MYSQL from Fuzzymonkey.com. The index.cgi uses sitevariables.pm for all paths and anything else it needs. The problem is that the script cannot find MYSQL.The scripts has the following snippit to call the MYSQL

    if ($dbh = DBI->connect("dbi:mysql:$svb::mysqldb","$svb::mysqluser","$svb::mysqlpass"))

    here is the error I get

    [Mon May 4 07:53:12 2009] index.cgi: DBI connect('rlw.hypermartmysql.com','rlw',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /home/users/web/b1263/hy.rlw/cgi-bin/class/index.cgi line 39

    here are the settings for this line of code

    our $mysqluser = 'rlw';
    our $mysqlpass = 'deadly';
    our $mysqldb = 'rlw.hypermartmysql.com'

    when I am in MYSQL and have it generate a code it gives me the following

    $db = DBI->connect('dbi:mysql:rlw:rlw.hypermartmysql.com:3306','rlw','deadly') or die('Couldnot connect');

    I replaced the privious code with this changing $db to dbh and had a syntax error that I fixed and now I get


    (https://protected.hypermart.net/rlw/...emplate.html): No such file or directory

    am really new to this and need some help
    Dutch

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,869
    Thanks
    2
    Thanked 163 Times in 158 Posts
    Contact your webhost. That is a mysql error that could have several causes, each of which requires the webserver admin. The mysql service may not be running, or there is a conflict in its config as to where to find the mysqld.sock file.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    Contact your webhost. That is a mysql error that could have several causes, each of which requires the webserver admin. The mysql service may not be running, or there is a conflict in its config as to where to find the mysqld.sock file.
    have contacted them and they ran a test and said that mysql is running. Although from what I can see they used php to access it.

    <?php $con = mysql_connect("rlw.hypermartmysql.com","rlw","deadly"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo "Connected successfully"; ?>

    even so I used the same db the same user and the same password. so it should work for me.

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,869
    Thanks
    2
    Thanked 163 Times in 158 Posts
    If you're receiving the "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' " error, but the test that your host performed didn't, then it's a permissions issue, which the webserver admin may need to correct.

    Is the script running under strictures and warnings? Meaning, does it have these use statements?
    Code:
    use strict;
    use warnings;
    Does it also have this statement?
    Code:
    use CGI::Carp qw(fatalsToBrowser);
    Can you post a more complete sample of your script and any/all warnings and errors that it produces?

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    If you're receiving the "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' " error, but the test that your host performed didn't, then it's a permissions issue, which the webserver admin may need to correct.

    Is the script running under strictures and warnings? Meaning, does it have these use statements?
    Code:
    use strict;
    use warnings;
    Does it also have this statement?
    Code:
    use CGI::Carp qw(fatalsToBrowser);
    Can you post a more complete sample of your script and any/all warnings and errors that it produces?
    have the permissions set right for the script if that is what you mean,

    also have the [code]use strict; and [CODE]use CGI::Carp qw(fatalsToBrowser);
    tried to attach the index.cgi but it will not let me

  • #6
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,869
    Thanks
    2
    Thanked 163 Times in 158 Posts
    I was referring to the permissions on the database.

    CF restricts the type and size of attachments.

    Attach it as a zip file and keep it under 50k.

  • #7
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    checked the permissions in the database and they are all set to yes, attached is the index.cgi ans the sitevariables.pm .hope this helps
    Attached Files Attached Files

  • #8
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Code:
    #!/usr/bin/perl
    
    use warnings;
    use strict;
    use CGI::Carp qw(fatalsToBrowser);
    use CGI;
    my $cgi = new CGI;
    print $cgi->header;
    print $cgi->start_html('Test');
    
    
    ##########################
    my $database = "test";
    my $host = "localhost";
    my $username = "u";
    my $password = "p";
    ##########################
    
    use ExtUtils::Installed;
    my $instmod = ExtUtils::Installed->new();
    print "<b>Installed Module</b><br/>";
    foreach my $module ($instmod->modules())
    {
        my $version = $instmod->version($module) || "???";
        print "$module -- $version<br/>";
    }
    
    use DBI;
    my @drivers;
    @drivers = DBI->available_drivers();
    print "<br/><br/><b>Here are a list of available drivers:</b><br/>";
    foreach (@drivers)
    {
        print "$_ driver is available<br/>";
    }
    
    my $dsn = "dbi:mysql:database=$database;hostname=$host";
    my %attr = (
        PrintError => 0,
        RaiseError => 0
    );
    #connect to database
    my $dbh = DBI->connect($dsn, $username, $password, \%attr)
    or die "Cannot connect to database: $DBI::errstr";
    if($dbh)
    {
        print "<b>Database is fine.</b><br/>";
    }
    $dbh->disconnect();
    
    
    
    print $cgi->end_html();
    What about running this test on your host, make sure that you can see DBD::mysql in the install moule

  • #9
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kokjj87 View Post
    Code:
    #!/usr/bin/perl
    
    use warnings;
    use strict;
    use CGI::Carp qw(fatalsToBrowser);
    use CGI;
    my $cgi = new CGI;
    print $cgi->header;
    print $cgi->start_html('Test');
    
    
    ##########################
    my $database = "test";
    my $host = "localhost";
    my $username = "u";
    my $password = "p";
    ##########################
    
    use ExtUtils::Installed;
    my $instmod = ExtUtils::Installed->new();
    print "<b>Installed Module</b><br/>";
    foreach my $module ($instmod->modules())
    {
        my $version = $instmod->version($module) || "???";
        print "$module -- $version<br/>";
    }
    
    use DBI;
    my @drivers;
    @drivers = DBI->available_drivers();
    print "<br/><br/><b>Here are a list of available drivers:</b><br/>";
    foreach (@drivers)
    {
        print "$_ driver is available<br/>";
    }
    
    my $dsn = "dbi:mysql:database=$database;hostname=$host";
    my %attr = (
        PrintError => 0,
        RaiseError => 0
    );
    #connect to database
    my $dbh = DBI->connect($dsn, $username, $password, \%attr)
    or die "Cannot connect to database: $DBI::errstr";
    if($dbh)
    {
        print "<b>Database is fine.</b><br/>";
    }
    $dbh->disconnect();
    
    
    
    print $cgi->end_html();
    What about running this test on your host, make sure that you can see DBD::mysql in the install moule
    that snippit worked just dandy. I used rlw and my password and it gave me a page full. Yes it has DBD::mysql .At the end it says Database is fine.
    might my problem be with the way I set up my tables? I imported them from my desktop

  • #10
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My web host provides a Script Checker so I ran my index.cgi with it. here are the results,

    Checked home/cgi-bin/class/index.cgi


    [Fri May 15 13:34:05 2009] index.cgi: Can't locate common.pm in @INC

    (@INC contains: ./lib /etc/perl /usr/local/lib/perl/5.8.8

    /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5

    /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl/5.8.8

    /usr/local/lib/site_perl /usr/local/lib/perl/5.8.4

    /usr/local/share/perl/5.8.4 .) at

    /home/users/web/b1263/hy.rlw/cgi-bin/class/index.cgi line 30.

    [Fri May 15 13:34:05 2009] index.cgi: BEGIN failed--compilation

    aborted at /home/users/web/b1263/hy.rlw/cgi-bin/class/index.cgi line

    30.

    Content-type: text/html


    <h1>Software error:</h1>

    <pre>Can't locate common.pm in @INC (@INC contains: ./lib /etc/perl

    /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5

    /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8

    /usr/local/lib/site_perl/5.8.8 /usr/local/lib/site_perl

    /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 .) at

    /home/users/web/b1263/hy.rlw/cgi-bin/class/index.cgi line 30.

    BEGIN failed--compilation aborted at

    /home/users/web/b1263/hy.rlw/cgi-bin/class/index.cgi line 30.

    </pre>

    <p>


    Maybe you know what it is telling me.

  • #11
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,869
    Thanks
    2
    Thanked 163 Times in 158 Posts
    Can't locate common.pm in @INC
    Perl is telling that it can't find the common.pm module in any of the directories that it's configured for holding modules.

    Do you have that file? If so, what is the exact path to that file?

    Did the classifieds script from Fuzzymonkey.com come with a README or similar file that gives installation instructions. If so, did you follow those instructions exactly, or did you take some short cuts?

  • #12
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    Perl is telling that it can't find the common.pm module in any of the directories that it's configured for holding modules.

    Do you have that file? If so, what is the exact path to that file?

    Did the classifieds script from Fuzzymonkey.com come with a README or similar file that gives installation instructions. If so, did you follow those instructions exactly, or did you take some short cuts?
    FishMonger , followed the instructions to a T. and all permissions are set right.
    https://protected.xxxxxxxxx.net/rlw/.../lib/common.pm is where common.pm resides and yes it is there right where it is supposed to be. index is at https://protected.xxxxxxxxx.net/rlw/...lass/index.cgi
    I have installed other perl programs with little or no problem but this is the first using mysql

  • #13
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,869
    Thanks
    2
    Thanked 163 Times in 158 Posts
    When I asked about the path to common.pm, I was referring to the system path, not a web url.

    What is the exact system path of index.cgi and common.pm?

    If you followed the installation instructions correctly, then I'd say that there is a bug/error in those instructions. Have you contacted the author of the script? Do they provide any support for their app?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •