Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-11-2009, 05:13 PM   PM User | #1
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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
padutch is offline   Reply With Quote
Old 05-11-2009, 06:59 PM   PM User | #2
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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.
FishMonger is offline   Reply With Quote
Old 05-11-2009, 07:19 PM   PM User | #3
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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.
padutch is offline   Reply With Quote
Old 05-11-2009, 09:12 PM   PM User | #4
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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?
FishMonger is offline   Reply With Quote
Old 05-11-2009, 10:09 PM   PM User | #5
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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
padutch is offline   Reply With Quote
Old 05-11-2009, 10:14 PM   PM User | #6
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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.
FishMonger is offline   Reply With Quote
Old 05-12-2009, 08:11 PM   PM User | #7
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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
File Type: zip script.zip (10.6 KB, 103 views)
padutch is offline   Reply With Quote
Old 05-13-2009, 07:29 PM   PM User | #8
kokjj87
Regular Coder

 
kokjj87's Avatar
 
Join Date: Sep 2008
Location: Singapore
Posts: 279
Thanks: 1
Thanked 55 Times in 54 Posts
kokjj87 is on a distinguished road
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
kokjj87 is offline   Reply With Quote
Old 05-14-2009, 09:12 PM   PM User | #9
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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
padutch is offline   Reply With Quote
Old 05-15-2009, 06:49 PM   PM User | #10
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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.
padutch is offline   Reply With Quote
Old 05-16-2009, 12:09 AM   PM User | #11
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
Quote:
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?
FishMonger is offline   Reply With Quote
Old 05-16-2009, 12:56 AM   PM User | #12
padutch
New to the CF scene

 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padutch is an unknown quantity at this point
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
padutch is offline   Reply With Quote
Old 05-16-2009, 12:36 PM   PM User | #13
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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?
FishMonger is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:20 AM.


Advertisement
Log in to turn off these ads.