Error connecting to remote database

Discussion in 'Perl Misc' started by skieros, Apr 16, 2007.

  1. skieros

    skieros Guest

    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
    skieros, Apr 16, 2007
    #1
    1. Advertising

  2. skieros

    skieros Guest

    On Apr 16, 4:03 pm, "skieros" <> 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, 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...
    skieros, Apr 16, 2007
    #2
    1. Advertising

  3. skieros

    skieros Guest

    On Apr 16, 4:03 pm, "skieros" <> 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 ?!
    skieros, Apr 16, 2007
    #3
  4. skieros

    Ian Wilson Guest

    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.
    Ian Wilson, Apr 16, 2007
    #4
  5. skieros

    skieros Guest

    On Apr 16, 4:45 pm, Ian Wilson <> 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,
    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
    skieros, Apr 16, 2007
    #5
  6. skieros

    Ian Wilson Guest

    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.
    Ian Wilson, Apr 16, 2007
    #6
  7. skieros

    skieros Guest

    On Apr 16, 7:37 pm, Ian Wilson <> 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;
    skieros, Apr 16, 2007
    #7
  8. skieros

    skieros Guest

    On Apr 16, 7:37 pm, Ian Wilson <> 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
    skieros, Apr 16, 2007
    #8
  9. skieros wrote:
    > On Apr 16, 7:37 pm, Ian Wilson <> 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 :)
    RedGrittyBrick, Apr 16, 2007
    #9
  10. skieros

    skieros Guest

    On Apr 17, 12:41 am, RedGrittyBrick <>
    wrote:
    > skieros wrote:
    > > On Apr 16, 7:37 pm, Ian Wilson <> 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?
    skieros, Apr 16, 2007
    #10
  11. skieros

    -berlin.de Guest

    skieros <> wrote in comp.lang.perl.misc:
    > On Apr 17, 12:41 am, RedGrittyBrick <>
    > wrote:


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


    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
    -berlin.de, Apr 17, 2007
    #11
  12. skieros

    skieros Guest

    On Apr 17, 1:23 pm, -berlin.de wrote:
    > skieros <> wrote in comp.lang.perl.misc:
    >
    > > On Apr 17, 12:41 am, RedGrittyBrick <>
    > > wrote:
    > > > 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?

    >
    > 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.
    skieros, Apr 17, 2007
    #12
  13. skieros

    -berlin.de Guest

    <-berlin.de> wrote in comp.lang.perl.misc:
    > skieros <> wrote in comp.lang.perl.misc:
    > > On Apr 17, 12:41 am, RedGrittyBrick <>
    > > wrote:

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

    >
    > 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
    -berlin.de, Apr 17, 2007
    #13
  14. skieros

    skieros Guest

    On Apr 17, 1:34 pm, -berlin.de wrote:
    > <-berlin.de> wrote in comp.lang.perl.misc:
    >
    >
    >
    > > skieros <> wrote in comp.lang.perl.misc:
    > > > On Apr 17, 12:41 am, RedGrittyBrick <>
    > > > wrote:

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

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


    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! :)
    skieros, Apr 17, 2007
    #14
  15. skieros

    skieros Guest

    On Apr 19, 12:25 am, Joe Smith <> wrote:
    > skieros wrote:
    > > 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


    Ill try to keep this on mind next time i move my perl webpage in
    another server...thank you.
    skieros, Apr 18, 2007
    #15
  16. skieros

    Joe Smith Guest

    skieros wrote:
    > 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
    Joe Smith, Apr 18, 2007
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ann Marinas
    Replies:
    12
    Views:
    733
    Guest
    May 5, 2005
  2. hfk0
    Replies:
    2
    Views:
    21,642
  3. Paul Watt

    error when connecting to database

    Paul Watt, May 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    390
    Mark Fitzpatrick
    May 10, 2006
  4. Beppe
    Replies:
    1
    Views:
    309
  5. madan
    Replies:
    1
    Views:
    112
    David Squire
    Jun 9, 2006
Loading...

Share This Page