Error connecting to remote database

S

skieros

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
 
S

skieros

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, (e-mail address 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...
 
S

skieros

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 ?!
 
I

Ian Wilson

skieros said:
#!/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.
 
S

skieros

It runs for me.



$ 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 address 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
 
I

Ian Wilson

skieros said:
<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.
 
S

skieros

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;
 
S

skieros

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
 
R

RedGrittyBrick

skieros said:
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 :)
 
S

skieros

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?
 
A

anno4000

skieros said:
On Apr 17, 12:41 am, RedGrittyBrick <[email protected]>
wrote:

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

and no error .displayed,why3?

Your exasperation is misdirected.

What RedGrittyBrick is trying to get through to you is that it's
your task to provide more information about what's happening. All
we can do is make guesses, which has availed nothing. So find out
how to access the error logs on your server. If that doesn't clear
things up for you, post the error message(s) and we'll see what we
can do.

Anno
 
S

skieros

Your exasperation is misdirected.

What RedGrittyBrick is trying to get through to you is that it's
your task to provide more information about what's happening. All
we can do is make guesses, which has availed nothing. So find out
how to access the error logs on your server. If that doesn't clear
things up for you, post the error message(s) and we'll see what we
can do.

Anno

Good news folks!

They tolm me that on free palns i will not be able to have access to
errro and access logs but they point the error.

My damn Gridinsoft Notepad ib=nsreted a bom header on top of all my
perl vgi scritps that i have saves as utf-8.

this to be exact: A?A»A?#!/usr/bin/perl -w

So when i uploaded thee server on freehostia coulsnt understand this
is a perl file thats why i got a premature display errors.

When is aved my scripts as windows encoding and uploded allorked fine.
check 4yourslef: skieros.freehostia.com :)

Whats troubles me though is with the same utf-8 encofing my webpage
was loaded fine in localhost.
 
A

anno4000

Your exasperation is misdirected.

What RedGrittyBrick is trying to get through to you is that it's
your task to provide more information about what's happening. All
we can do is make guesses, which has availed nothing. So find out
how to access the error logs on your server. If that doesn't clear
things up for you, post the error message(s) and we'll see what we
can do.

If your provider doesn't give you access to the logs (as seems to be
the case), change the provider. You don't have a chance to get anything
significant up and running under these conditions.

Anno
 
S

skieros

If your provider doesn't give you access to the logs (as seems to be
the case), change the provider. You don't have a chance to get anything
significant up and running under these conditions.

Anno

Well freehostia is considered to be the best free hosting provider,
they also tol me to net hesitate to ask them again if i have a similar
problem, but i still wont be able to read the access and error
log.....

Sorry, for yesteraday i want exasperating it was my keyboard driving
nuts after accidentally spitted coffe on it as i mentioned few minutes
ago on my another post! :)
 
S

skieros

First off, are you able to run any sort of perl script at all?

#!/usr/bin/perl
print "Content-type: text/plain\n\n Hello, world\n";

There is no point in going any further if that does not work.
-Joe

Ill try to keep this on mind next time i move my perl webpage in
another server...thank you.
 
J

Joe Smith

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

First off, are you able to run any sort of perl script at all?

#!/usr/bin/perl
print "Content-type: text/plain\n\n Hello, world\n";

There is no point in going any further if that does not work.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top