Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to access mysql using 'use DBI;' can't get link to database...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
0
0
i have created a database using cpanel/mysql called gtName_test with a table called candy...

***

#!/usr/bin/perl -w

use strict;
use CGI qw:)standard);
use DBI;

my $dbh = DBI->connect('dbi:mysql:gtName_test','','');

*** etc ***

although the script doesn't throw any error, i use the following test:

**
my $sql = "select name from candy";

my $sth = $dbh->prepare($sql);

$sth->execute || die "Could not execute SQL statement ... maybe invalid?";

while (@row=$sth->fetchrow_array)
{ print "@row\n" }

**

not even the error for "Could not execute..." comes up which tells me that it's not even getting to that point.

i have the correct table, 'candy', and i have a name field...

i'm following stuff for perl/mysql online but none of it works.

help please?

- g
 
examine $DBI::errstr after the line:

my $dbh = DBI->connect('dbi:mysql:gtName_test','','');

that should give you an idea of what is wrong

What port of Perl are you using? ActiveState?

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 

i'm using whatever port my server company uses...

i don't get what you mean...there is no error...or should i actually put DBI::errstr somewhere...

and thank you...

- g
 
Yes check the contents of $DBI::errstr to see what hte problem is.

 
Like this:
Code:
my $dbh = DBI->connect('dbi:mysql:gtName_test','','')
[tab]|| die "Connection problem: $DBI::errstr\n";

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Do you have the permissions to log on w/out username and password? I wouldn't be suprised if you are getting a permission denied error

- E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top