Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   connecting to mysql (http://www.velocityreviews.com/forums/t886063-connecting-to-mysql.html)

user99 04-22-2004 01:12 PM

connecting to mysql
 
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;

Gunnar Hjalmarsson 04-22-2004 01:55 PM

Re: connecting to mysql
 
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/cl...uidelines.html

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Glenn Jackman 04-22-2004 03:23 PM

Re: connecting to mysql
 
user99 <user99@austin.rr.com> 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
glennj@ncf.ca

Tore Aursand 04-22-2004 05:51 PM

Re: connecting to mysql
 
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 <tore@aursand.no>
"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)

user99 04-22-2004 06:20 PM

Re: connecting to mysql
 
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c68j8m$9a3jj$1@ID-184292.news.uni-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/cl...uidelines.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.

Tad McClellan 04-22-2004 06:41 PM

Re: connecting to mysql
 
user99 <user99@austin.rr.com> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c68j8m$9a3jj$1@ID-184292.news.uni-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
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Glenn Jackman 04-22-2004 06:53 PM

Re: connecting to mysql
 
Tore Aursand <tore@aursand.no> 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
glennj@ncf.ca

Sherm Pendley 04-22-2004 08:47 PM

Re: connecting to mysql
 
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

Sam Holden 04-22-2004 09:58 PM

Re: connecting to mysql
 
On 22 Apr 2004 11:20:48 -0700, user99 <user99@austin.rr.com> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c68j8m$9a3jj$1@ID-184292.news.uni-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/cl...uidelines.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


All times are GMT. The time now is 10:43 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.