in reply to Can't call method "prepare" on an undefined value

On an entirely different tack: are you sure you need to declare your variables as "local"?
At first glance, "my" seems more appropriate.

Also your die statement following the execute statement should really say "while executing SQL statement".

Of course this does not help you with your problem at all.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Can't call method "prepare" on an undefined value

Replies are listed 'Best First'.
Re: Re: Can't call method "prepare" on an undefined value
by Massyn (Hermit) on Dec 18, 2002 at 09:54 UTC

    I've played around with "strict" and "my", and funny enough, it doesn't fix the problem. I have found something else now... If I do not use procedures, ie. I do my mySQL connection, executing the SQL statement and disconnecting it all in one piece of code, it works fine, however, I'm using procedures to do that. I have a connection procedure, a disconnection procedure, and a SQL execution procedure. It looks like my $mwsdbh variable I receive from my connection is not a global variable, although it should be. When it comes to the execution of SQL statement procedure, the script dies.

    Have you guys seen this behaviour before? I've tried "returning" the variable, but that doesn't work.

    Thanks!

    #!/massyn.pl The more I learn, the more I realize I don't know. Albert Einstein 1879-1955

      Did you try sending the $mwsdbh variable as a parameter to the subroutines?
      That way it should be known and accessible in the subroutines.

      I'm still confused about the use you make of the "local" keyword for the declaration of your variables inside the subroutine. If you have a moment to spare, could you explain it?

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        I'm using local, so that the variables defined only stay within that procedure. They don't need to be global variables.

        As for your suggestion of passing the variable out, that didn't work. I guess that $mwsdbh is not really a scalar. How can I reference it properly?

        #!/massyn.pl The more I learn, the more I realize I don't know. Albert Einstein 1879-1955