Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > called too early to check prototype at

Reply
Thread Tools

called too early to check prototype at

 
 
Ron Eggler
Guest
Posts: n/a
 
      03-18-2008
Hi,

I get a "called too early to check prototype at" in my script and i have no
idea what this is referring to.It is pointing to this line:
for(my $count = 0; $count < scalar(@dbset); $count++){ which sits on top of
my file and is part of:
use DBI;
#
# Open the DB connection
#
my @dbset=(xmlparse($nemsconf,"DBNAME"));

for(my $count = 0; $count < scalar(@dbset); $count++){
my $myDBI = 'DBI:mysql:' . $dbset[$count] . ':localhost';
my $dbh = DBI->connect($myDBI,'root','novax')
or die "Couldn't connect to database: " . DBI->errstr . "\n";

Any idea what could be wrong here?

Thank you!
Ron
--
chEErs roN
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      03-19-2008
Ron Eggler <(E-Mail Removed)> wrote:
>Hi,
>
>I get a "called too early to check prototype at" in my script and i have no
>idea what this is referring to.It is pointing to this line:
>for(my $count = 0; $count < scalar(@dbset); $count++)


This can be rewritten in a much easier to read way as
for my $count (0..@dbset-1)

>for(my $count = 0; $count < scalar(@dbset); $count++){
> my $myDBI = 'DBI:mysql:' . $dbset[$count] . ':localhost';
> my $dbh = DBI->connect($myDBI,'root','novax')
> or die "Couldn't connect to database: " . DBI->errstr . "\n";


However, as you don't do anything with $count but to index the array in a
linear fashion it is even easier to use a simple

for(@dbset){
my $myDBI = "DBI:mysql:$_ :localhost";
....

jue
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      03-19-2008

Quoth Ron Eggler <(E-Mail Removed)>:
> Hi,
>
> I get a "called too early to check prototype at" in my script and i have no
> idea what this is referring to.It is pointing to this line:
> for(my $count = 0; $count < scalar(@dbset); $count++){ which sits on top of
> my file and is part of:
> use DBI;
> #
> # Open the DB connection
> #
> my @dbset=(xmlparse($nemsconf,"DBNAME"));


Have you by any chance declared xmlparse below like this

sub xmlparse() {

? This is not how you declare a Perl sub. Remove the ().

If not, you will need to reduce your problem to a *small*
*self-contained* program *we can all run*, or we can't help you.

Ben

 
Reply With Quote
 
Ron Eggler
Guest
Posts: n/a
 
      03-19-2008
Jürgen Exner wrote:

> for(@dbset){
> my $myDBI = "DBI:mysql:$_ :localhost";


Alright,

Thanks for that but when i try it like this:
#
# Open the DB connection
#
my @dbset=(xmlparse($nemsconf,"DBNAME"));
print "DB name: ". xmlparse($nemsconf,"DBNAME")."\n";
#for(my $count = 0; $count < scalar(@dbset); $count++){
# my $myDBI = 'DBI:mysql:' . $dbset[$count] . ':localhost';
for(@dbset){
my $myDBI = "DBI:mysql:$_ :localhost";
my $dbh =
DBI->connect($myDBI,xmlparse($nemsconf,"DBUSER"),xmlpa rse($nemsconf,"DBPASS"))
or die "Couldn't connect to database: " . DBI->errstr . "\n";
}

It's telling me only:
[shell]
DB name: toronto
DBI connect('toronto :localhost','root',...) failed: Incorrect database
name 'toronto ' at ./log_parser.pl line 39
Couldn't connect to database: Incorrect database name 'toronto '
[/shell]
eventho i can connect nicely with:
mysql -u root -p toronto

any idea what could be wrong there?
I first thought where it says "Couldn't connect to database: Incorrect
database name 'toronto '" that would be a mistake because of the space at
the end but when I hardcode "toronto" it is displaaying it the same way. So
I'm pretty stuck here.
Thanks for any further help!
--
Ron
 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      03-20-2008
Jürgen Exner schreef:

> for my $count (0..@dbset-1)



Alternatives:

for my $count ( 0 .. $#dbset )

for my $count ( $[ .. $#dbset )

--
Affijn, Ruud

"Gewoon is een tijger."

 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      03-20-2008
Ron Eggler wrote:
> J�rgen Exner wrote:
>
>> for(@dbset){
>> my $myDBI = "DBI:mysql:$_ :localhost";

>
> Alright,
>
> Thanks for that but when i try it like this:
> #
> # Open the DB connection
> #
> my @dbset=(xmlparse($nemsconf,"DBNAME"));
> print "DB name: ". xmlparse($nemsconf,"DBNAME")."\n";
> #for(my $count = 0; $count < scalar(@dbset); $count++){
> # my $myDBI = 'DBI:mysql:' . $dbset[$count] . ':localhost';
> for(@dbset){
> my $myDBI = "DBI:mysql:$_ :localhost";
> my $dbh =
> DBI->connect($myDBI,xmlparse($nemsconf,"DBUSER"),xmlpa rse($nemsconf,"DBPASS"))
> or die "Couldn't connect to database: " . DBI->errstr . "\n";
> }
>
> It's telling me only:
> [shell]
> DB name: toronto
> DBI connect('toronto :localhost','root',...) failed: Incorrect database
> name 'toronto ' at ./log_parser.pl line 39
> Couldn't connect to database: Incorrect database name 'toronto '

Remove the space.

my $myDBI = "DBI:mysql:$_:localhost";

And check the value.

print "myDBI=$myDBI\n"; #maybe there's a newline? If so, chomp.

> [/shell]
> eventho i can connect nicely with:
> mysql -u root -p toronto
>
> any idea what could be wrong there?
> I first thought where it says "Couldn't connect to database: Incorrect
> database name 'toronto '" that would be a mistake because of the space at
> the end but when I hardcode "toronto" it is displaaying it the same way. So
> I'm pretty stuck here.


Go back to the basics.

use DBI;
my $myDBI = 'DBI:mysql:toronto:localhost';
my $user = 'someuser';
my $pw = 'somepw';
my $dbh = DBI->connect( $myDBI, $user, $pw )
or die "Couldn't connect to database: " . DBI->errstr . "\n";

If that works then verify the values of $user, $pw, and $myDBI are
what you expect.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class prototype vs C function prototype June Lee C++ 2 04-13-2008 08:17 PM
Is it too early - or is it too late. Knut Arvid Keilen Computer Support 1 02-25-2008 09:41 AM
Prototype Object.extend(new Base() | Hash | Hash.prototype) usage: jacobstr@gmail.com Javascript 3 03-27-2007 07:56 AM
relation between prototype and Prototype.js shypen42@yahoo.fr Javascript 9 05-26-2006 01:13 AM
Sesson_End called too early Kostia ASP .Net 7 10-21-2004 09:53 PM



Advertisments