connecting to mysql

U

user99

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

Gunnar Hjalmarsson

user99 said:
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
 
G

Glenn Jackman

user99 said:
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)
 
T

Tore Aursand

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

user99

Gunnar Hjalmarsson said:
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.
 
G

Glenn Jackman

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

Sherm Pendley

user99 said:
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:

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

Sam Holden

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.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top