Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Error connecting to remote database

Reply
Thread Tools

Error connecting to remote database

 
 
skieros
Guest
Posts: n/a
 
      04-16-2007
my $dbh = DBI->connect('DBI:mysql:;host=mysql3.freehostia.com' ,
'nikkou6', '********', {RaiseError=>1});
or
my $dbh = DBI->connect('DBI:mysql:' 'root', '********',
{RaiseError=>1});

Is the above likely to work?
I made it liek these so for init.pl to have a knowledge of wether it
runs on localhost or on freehostia.com which is my remote hosting
company.

For some reason it aint working...but i don't see the error.

Matt said:
I would expect that when connecting to MySQL without specifying a
database you will connect by default to the "mysql" database (if the
lack of a default database isn't the error; never tried), and I doubt
very highly that your host would allow you in there. You might try
adding a die statement if you don't get a handle so you know what went
wrong and so your code doesn't continue on when it shouldn't:

my $dbh = DBI->connect() or die $DBI::errstr;

Matt

 
Reply With Quote
 
 
 
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 4:03 pm, "skieros" <(E-Mail Removed)> wrote:
> my $dbh = DBI->connect('DBI:mysql:;host=mysql3.freehostia.com' ,
> 'nikkou6', '********', {RaiseError=>1});
> or
> my $dbh = DBI->connect('DBI:mysql:' 'root', '********',
> {RaiseError=>1});
>
> Is the above likely to work?
> I made it liek these so for init.pl to have a knowledge of wether it
> runs on localhost or on freehostia.com which is my remote hosting
> company.
>
> For some reason it aint working...but i don't see the error.
>
> Matt said:
> I would expect that when connecting to MySQL without specifying a
> database you will connect by default to the "mysql" database (if the
> lack of a default database isn't the error; never tried), and I doubt
> very highly that your host would allow you in there. You might try
> adding a die statement if you don't get a handle so you know what went
> wrong and so your code doesn't continue on when it shouldn't:
>
> my $dbh = DBI->connect() or die $DBI::errstr;
>
> Matt


Yes Matt i tried what you said and i got this:

Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, http://www.velocityreviews.com/forums/(E-Mail Removed) and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.

More information about this error may be available in the server error
log.

Apache/1.3.33 Server at skieros.freehostia.com Port 80

So, i cant veen get a proper handle! But whast the goo of a free web
hostign compnay if they dont let you connect to their mysql server so
you can create withing your perl script your mysql database and
tables...

 
Reply With Quote
 
 
 
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 4:03 pm, "skieros" <(E-Mail Removed)> wrote:
> my $dbh = DBI->connect('DBI:mysql:;host=mysql3.freehostia.com' ,
> 'nikkou6', '********', {RaiseError=>1});
> or
> my $dbh = DBI->connect('DBI:mysql:' 'root', '********',
> {RaiseError=>1});
>
> Is the above likely to work?
> I made it liek these so for init.pl to have a knowledge of wether it
> runs on localhost or on freehostia.com which is my remote hosting
> company.
>
> For some reason it aint working...but i don't see the error.
>
> Matt said:
> I would expect that when connecting to MySQL without specifying a
> database you will connect by default to the "mysql" database (if the
> lack of a default database isn't the error; never tried), and I doubt
> very highly that your host would allow you in there. You might try
> adding a die statement if you don't get a handle so you know what went
> wrong and so your code doesn't continue on when it shouldn't:
>
> my $dbh = DBI->connect() or die $DBI::errstr;
>
> Matt


Now that i made a very simple perl cgi script the following:

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;


print header( -charset=>'utf-8' );
print start_html( -title=>'Ψυχωφελή Πνευματικά Κείμενα!' );

print "hello" or die $!;

is aw that this very simplistic script WONT even run, it dies
prematurely even before displaying a print eeror!

WHY ?!

 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      04-16-2007
skieros wrote:
> #!/usr/bin/perl -w
> use strict;
> use CGI::Carp qw(fatalsToBrowser);
> use CGI qw(:standard);
> use DBI;
>
> print header( -charset=>'utf-8' );
> print start_html( -title=>'Ψυχωφελή Πνευματικά Κείμενα!' );
>
> print "hello" or die $!;
>
> is aw that this very simplistic script WONT even run,


It runs for me.

> it dies prematurely even before displaying a print eeror!
>
> WHY ?!
>


$ perl skieros.pl
Content-Type: text/html; charset=utf-8

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><title>....φε.. ..ε..ατ... .ε..ε.α!</title>


I haven't set up the right locale or font but the program runs fine.
Maybe you should elaborate on what you mean by "dies" and what you found
in your web-server's access log and error log.

It's probably a mistake to mix CGI.pm and and-written HTML so
change
print "hello" or die $!;
to
print p('hello') or die $!;
print end_html;

I'm not sure why you have the `or die` since you already specified
fatalsToBrowser and you don't have `or die` elsewhere.
 
Reply With Quote
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 4:45 pm, Ian Wilson <(E-Mail Removed)> wrote:
> skieros wrote:
> > #!/usr/bin/perl -w
> > use strict;
> > use CGI::Carp qw(fatalsToBrowser);
> > use CGI qw(:standard);
> > use DBI;

>
> > print header( -charset=>'utf-8' );
> > print start_html( -title=>'Ψυχωφελή Πνευματικά Κείμενα!' );

>
> > print "hello" or die $!;

>
> > is aw that this very simplistic script WONT even run,

>
> It runs for me.
>
> > it dies prematurely even before displaying a print eeror!

>
> > WHY ?!

>
> $ perl skieros.pl
> Content-Type: text/html; charset=utf-8
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> lang="en-US"><head><title>....φε.. ..ε..ατ... .ε..ε.α!</title>
>
> I haven't set up the right locale or font but the program runs fine.
> Maybe you should elaborate on what you mean by "dies" and what you found
> in your web-server's access log and error log.
>
> It's probably a mistake to mix CGI.pm and and-written HTML so
> change
> print "hello" or die $!;
> to
> print p('hello') or die $!;
> print end_html;
>
> I'm not sure why you have the `or die` since you already specified
> fatalsToBrowser and you don't have `or die` elsewhere.


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
(E-Mail Removed) and inform them of the time the error
occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>Apache/1.3.33 Server at skieros.freehostia.com Port 80</
ADDRESS>
</BODY></HTML>

when i try to http://skieros.freehostia.com/cgi-bin/test.pl

 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      04-16-2007
skieros wrote:
> <TITLE>500 Internal Server Error</TITLE>
>
> when i try to http://skieros.freehostia.com/cgi-bin/test.pl
>


You need to check the Apache error log. I don't know about
freehostia.com but my hosting providers provide separate error logs for
each customer.

Its a bit pointless to speculate about the error, it might be
permissions on the test.pl file, it might be a malformed first line.
Read the error message in the Apache error log.
 
Reply With Quote
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 7:37 pm, Ian Wilson <(E-Mail Removed)> wrote:
> skieros wrote:
> > <TITLE>500 Internal Server Error</TITLE>

>
> > when i try tohttp://skieros.freehostia.com/cgi-bin/test.pl

>
> You need to check the Apache error log. I don't know about
> freehostia.com but my hosting providers provide separate error logs for
> each customer.
>
> Its a bit pointless to speculate about the error, it might be
> permissions on the test.pl file, it might be a malformed first line.
> Read the error message in the Apache error log.


I wish i could!! Then i wouldnt speculate any more.

As for permission i ahve set them to all my uploaded files to chmod
755 *

As for the perl script it self it laods ok in my localhost.

The weird part is that even if i sue FatalsToBrowser i see no error in
my browser just like the webpage cant even read the initial perl
modules of:

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;

Isnt it weird that it cant even get to then print hello or die
statement?

print header( -charset=>'utf-8' );
print start_html( -title=>'Hello World!' );


print p('hello') or die $!;
print end_html;

 
Reply With Quote
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 7:37 pm, Ian Wilson <(E-Mail Removed)> wrote:
> skieros wrote:
> > <TITLE>500 Internal Server Error</TITLE>

>
> > when i try tohttp://skieros.freehostia.com/cgi-bin/test.pl

>
> You need to check the Apache error log. I don't know about
> freehostia.com but my hosting providers provide separate error logs for
> each customer.
>
> Its a bit pointless to speculate about the error, it might be
> permissions on the test.pl file, it might be a malformed first line.
> Read the error message in the Apache error log.


Thay just answred me like this:

Hello,

I am truly sorry to disappoint you but Access and Error logs service
in not available at this time. Our administrators are working to
enable it as soon as possible.

Best Regards,
Bob

 
Reply With Quote
 
RedGrittyBrick
Guest
Posts: n/a
 
      04-16-2007
skieros wrote:
> On Apr 16, 7:37 pm, Ian Wilson <(E-Mail Removed)> wrote:
>> skieros wrote:
>>> <TITLE>500 Internal Server Error</TITLE>
>>> when i try tohttp://skieros.freehostia.com/cgi-bin/test.pl

>> You need to check the Apache error log. I don't know about
>> freehostia.com but my hosting providers provide separate error logs for
>> each customer.

> I wish i could!! Then i wouldnt speculate any more.



> Isnt it weird that it cant even get to then print hello or die
> statement?


It isn't very wierd really. IIRC it means that either the Perl
interpreter isn't being invoked (e.g. its not installed at /usr/bin) or
the program failed with a compiler error rather than a run-time error.
(though frankly I'm a bit hazy about this distinction with perl)

Consider this CGI script accessed via a web browser:

#!perl
use strict;
use warnings;
use DBI;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print header( -charset=>'utf-8' ),
start_html( -title=>'Hello World!' ),
p('hello'),
end_html;

Apache produces a 500 error.

Now consider this

#!perl
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;
print header( -charset=>'utf-8' ),
start_html( -title=>'Hello World!' ),
p('hello'),
end_html;

The browser displays "Can't locate DBI.pm in @INC (@INC contains: ..."
This is because I moved the `use CGI::Carp` before the `use DBI` (which
isn't installed).

You can install Apache on your WinXP PC and test your CGI scripts that
way. At least you'll have access to error logs
 
Reply With Quote
 
skieros
Guest
Posts: n/a
 
      04-16-2007
On Apr 17, 12:41 am, RedGrittyBrick <(E-Mail Removed)>
wrote:
> skieros wrote:
> > On Apr 16, 7:37 pm, Ian Wilson <(E-Mail Removed)> wrote:
> >> skieros wrote:
> >>> <TITLE>500 Internal Server Error</TITLE>
> >>> when i try tohttp://skieros.freehostia.com/cgi-bin/test.pl
> >> You need to check the Apache error log. I don't know about
> >> freehostia.com but my hosting providers provide separate error logs for
> >> each customer.

> > I wish i could!! Then i wouldnt speculate any more.
> > Isnt it weird that it cant even get to then print hello or die
> > statement?

>
> It isn't very wierd really. IIRC it means that either the Perl
> interpreter isn't being invoked (e.g. its not installed at /usr/bin) or
> the program failed with a compiler error rather than a run-time error.
> (though frankly I'm a bit hazy about this distinction with perl)
>
> Consider this CGI script accessed via a web browser:
>
> #!perl
> use strict;
> use warnings;
> use DBI;
> use CGI::Carp qw(fatalsToBrowser);
> use CGI qw(:standard);
> print header( -charset=>'utf-8' ),
> start_html( -title=>'Hello World!' ),
> p('hello'),
> end_html;
>
> Apache produces a 500 error.
>
> Now consider this
>
> #!perl
> use strict;
> use warnings;
> use CGI::Carp qw(fatalsToBrowser);
> use CGI qw(:standard);
> use DBI;
> print header( -charset=>'utf-8' ),
> start_html( -title=>'Hello World!' ),
> p('hello'),
> end_html;
>
> The browser displays "Can't locate DBI.pm in @INC (@INC contains: ..."
> This is because I moved the `use CGI::Carp` before the `use DBI` (which
> isn't installed).
>
> You can install Apache on your WinXP PC and test your CGI scripts that
> way. At least you'll have access to error logs


Yes i use dbi.pm. the .way .you .describe.

and no error .displayed,why3?

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Connecting Pc remote with database Mysql Beppe Java 1 04-13-2008 06:24 PM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM



Advertisments