Choosing the correct mysql server to connect to

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', 'tiabhp2r', {RaiseError=>1});
    or
    my $dbh = DBI->connect('DBI:mysql:' 'root', 'tiabhp2r',
    {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 aitn working...but i dnt see the error.
     
    skieros, Apr 16, 2007
    #1
    1. Advertising

  2. skieros

    Matt Garrish Guest

    On Apr 16, 8:08 am, "skieros" <> wrote:
    > my $dbh = DBI->connect('DBI:mysql:;host=mysql3.freehostia.com',
    > 'nikkou6', 'tiabhp2r', {RaiseError=>1});
    > or
    > my $dbh = DBI->connect('DBI:mysql:' 'root', 'tiabhp2r',
    > {RaiseError=>1});
    >
    > Is the above likely to work?


    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
     
    Matt Garrish, Apr 16, 2007
    #2
    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. nospam
    Replies:
    13
    Views:
    615
  2. =?ISO-8859-1?Q?Ren=E9_Kjellerup?=

    How to connect to MYSQL server from c++ script

    =?ISO-8859-1?Q?Ren=E9_Kjellerup?=, Feb 3, 2004, in forum: C++
    Replies:
    1
    Views:
    452
    Marcin Marek
    Feb 4, 2004
  3. Allen Marshall
    Replies:
    1
    Views:
    196
    Gunnar Hjalmarsson
    Jan 24, 2004
  4. Replies:
    2
    Views:
    300
  5. Aseem Bansal
    Replies:
    8
    Views:
    75
    Aseem Bansal
    May 24, 2014
Loading...

Share This Page