connecting to mysql

Discussion in 'Perl Misc' started by user99, Apr 22, 2004.

  1. user99

    user99 Guest

    can't get this script to work. running mysql server on
    windows 2000 and i granted all to ''@'localhost'.
    any ideas?

    #!\perl\bin\perl

    use CGI qw(param);
    use DBI;
    my $action = param("Action");
    my $select = param("select");
    if ($action eq "Results") {
    my $dbh = DBI->connect('DBI:mysql:database01:localhost','','');
    if ( not $dbh ) {
    $h = "<H1>Bad connect";
    } else {
    $h = "<H1>Success";
    my $sth = $dbh->prepare("select * from votes where name = 'test'");
    $sth->execute();
    $dbh->disconnect;
    }
    &printHtml;
     
    user99, Apr 22, 2004
    #1
    1. Advertising

  2. user99 wrote:
    > can't get this script to work. running mysql server on windows
    > 2000 and i granted all to ''@'localhost'.
    > any ideas?


    Yes, make some debugging efforts, such as capturing the error
    message(s). Study the DBI docs for guidance.

    "can't get this script to work" is a terribly unappropriate problem
    description. You should study the posting guidelines for this group:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 22, 2004
    #2
    1. Advertising

  3. user99 <> wrote:
    > can't get this script to work. running mysql server on
    > windows 2000 and i granted all to ''@'localhost'.
    > any ideas?

    [...]
    > my $dbh = DBI->connect('DBI:mysql:database01:localhost','','');

    ^^^^^^^^^^ ^^^^^^^^^
    That looks wrong. Try
    my $dsn = 'DBI:mysql:database=database01:host=localhost';
    my $options = {RaiseError => 1};
    my $dbh = DBI->connect($dsn, '', '', $options);

    Read 'perldoc DBD::mysql' (online at
    http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm)


    --
    Glenn Jackman
    NCF Sysadmin
     
    Glenn Jackman, Apr 22, 2004
    #3
  4. user99

    Tore Aursand Guest

    On Thu, 22 Apr 2004 15:23:53 +0000, Glenn Jackman wrote:
    >> my $dbh = DBI->connect('DBI:mysql:database01:localhost','','');
    >> ^^^^^^^^^^ ^^^^^^^^^


    > That looks wrong. Try
    > my $dsn = 'DBI:mysql:database=database01:host=localhost';


    Hmm. That _also_ looks wrong. Shouldn't the values be separated by a
    semi-colon? In other words, something like this?

    my $dns = 'DBI:mysql:database=dbname;host=dbhost;port=dbport';

    Or is it possible to use both colon and semi-colon?


    --
    Tore Aursand <>
    "I know not with what weapons World War 3 will be fought, but World War
    4 will be fought with sticks and stones." (Albert Einstein)
     
    Tore Aursand, Apr 22, 2004
    #4
  5. user99

    user99 Guest

    Gunnar Hjalmarsson <> wrote in message news:<c68j8m$9a3jj$-berlin.de>...
    > user99 wrote:
    > > can't get this script to work. running mysql server on windows
    > > 2000 and i granted all to ''@'localhost'.
    > > any ideas?

    >
    > Yes, make some debugging efforts, such as capturing the error
    > message(s). Study the DBI docs for guidance.
    >
    > "can't get this script to work" is a terribly unappropriate problem
    > description. You should study the posting guidelines for this group:
    > http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


    ok, mr wise guy... This is what I get on the log when I run:
    <-Can't create TCP/IP socket (10106) error 2004 recorded: Can't create
    TCP/IP socket.

    The thing is if I run a similar version on dos it works, but when I
    run
    it as a cgi on tomcat it craps out....

    thank you very much for your useless help.
     
    user99, Apr 22, 2004
    #5
  6. user99 <> wrote:
    > Gunnar Hjalmarsson <> wrote in message news:<c68j8m$9a3jj$-berlin.de>...
    >> user99 wrote:


    >> > can't get this script to work.



    >> "can't get this script to work" is a terribly unappropriate problem
    >> description.



    > ok, mr wise guy...



    So long mister foolish guy.

    *plonk*


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 22, 2004
    #6
  7. Tore Aursand <> wrote:
    > On Thu, 22 Apr 2004 15:23:53 +0000, Glenn Jackman wrote:
    > >> my $dbh = DBI->connect('DBI:mysql:database01:localhost','','');

    >
    > > That looks wrong. Try
    > > my $dsn = 'DBI:mysql:database=database01:host=localhost';

    >
    > Hmm. That _also_ looks wrong. Shouldn't the values be separated by a
    > semi-colon? In other words, something like this?
    >
    > my $dns = 'DBI:mysql:database=dbname;host=dbhost;port=dbport';
    >
    > Or is it possible to use both colon and semi-colon?


    Ah, my mistake. 'host' is preceded by a semi-colon.

    --
    Glenn Jackman
    NCF Sysadmin
     
    Glenn Jackman, Apr 22, 2004
    #7
  8. user99 wrote:

    > ok, mr wise guy... This is what I get on the log when I run:
    > <-Can't create TCP/IP socket (10106) error 2004 recorded: Can't create
    > TCP/IP socket.


    This shows that Gunnar was correct about a number of things. First, that you
    need to brush up on your debugging skills; this is clearly not an "Access
    Denied" message from the MySQL server, so there's no logical reason to
    believe that any sort of grant would fix it.

    Also, Gunnar was correct in asking for more information. This error message
    is much more informative than "it doesn't work." Without this information,
    anyone who wants to help you is limited to offering blind (and most likely
    unhelpful) guesses.

    Here is a useful article:

    <http://www.catb.org/~esr/faqs/smart-questions.html>

    > thank you very much for your useless help.


    Unfortunately, with that sort of attitude, I don't think you'll find too
    many people here who are still willing to help you. Do you always respond
    to kindness with insults?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Apr 22, 2004
    #8
  9. user99

    Sam Holden Guest

    On 22 Apr 2004 11:20:48 -0700, user99 <> wrote:
    > Gunnar Hjalmarsson <> wrote in message news:<c68j8m$9a3jj$-berlin.de>...
    >> user99 wrote:
    >> > can't get this script to work. running mysql server on windows
    >> > 2000 and i granted all to ''@'localhost'.
    >> > any ideas?

    >>
    >> Yes, make some debugging efforts, such as capturing the error
    >> message(s). Study the DBI docs for guidance.
    >>
    >> "can't get this script to work" is a terribly unappropriate problem
    >> description. You should study the posting guidelines for this group:
    >> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

    >
    > ok, mr wise guy... This is what I get on the log when I run:
    ><-Can't create TCP/IP socket (10106) error 2004 recorded: Can't create
    > TCP/IP socket.
    >
    > The thing is if I run a similar version on dos it works, but when I
    > run
    > it as a cgi on tomcat it craps out....
    >
    > thank you very much for your useless help.


    Thank you for helping reduce the number of posts I need to read in this
    newsgroup to find the good ones.


    --
    Sam Holden
     
    Sam Holden, Apr 22, 2004
    #9
    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. Nikola Skoric

    connecting to mysql through DBI problem

    Nikola Skoric, Jan 14, 2004, in forum: Perl
    Replies:
    0
    Views:
    735
    Nikola Skoric
    Jan 14, 2004
  2. Philip Townsend

    connecting to mysql

    Philip Townsend, Jan 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    416
    Ken Cox [Microsoft MVP]
    Jan 22, 2004
  3. =?Utf-8?B?S2VubmV0aCBQ?=

    Connecting to MySql.Data.MySqlClient namespace

    =?Utf-8?B?S2VubmV0aCBQ?=, Dec 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    9,575
    Patrick Olurotimi Ige
    Jan 13, 2005
  4. Rajesh A via DotNetMonster.com

    MySQL Connecting Problume

    Rajesh A via DotNetMonster.com, Aug 5, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    454
    Mark Rae
    Aug 8, 2005
  5. dave
    Replies:
    4
    Views:
    1,373
    Steve Holden
    Nov 18, 2010
Loading...

Share This Page