Web Analytics Made Easy -
StatCounter sending dbh connection to a sub routine - CodingForum

Announcement

Collapse
No announcement yet.

sending dbh connection to a sub routine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resolved sending dbh connection to a sub routine

    Hi,

    In my script, I get a connection established with the db. I then want to send the connection to another sub but it seems not to happen.

    Can it not be done in the same way as any other value is passable from sub to sub?

    Code:
    sub db_connect {
    
      my $business_id = '123';
      my $connect = connect_to_db(); # connection established
    
      require 'header_control.pl';  # locate headers and footers module
      header($business_id,$connect);
    }
    second file:
    Code:
    header {
    
    my ($business_id,$connect) = @_;
    
    business_id value can be used
    connect value isn't there. 
    }
    The error msg says:
    Can't call method "prepare" on an undefined value at header_control.pl line 313.

    Can someone please show me a tutorial or give an explantion for what I have done wrongly.

    I may just be in one of my 'lets make this more efficient' moods which makes me run around in circles.

    bazz

    Edit:
    Blimey, sorry. I was looking at the wrong place It's working now.
    Last edited by bazz; Apr 2, 2009, 12:50 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link
Working...
X