1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Rep Power
    I need to get the info from $db in the following function. How the heck is that done ?

    function errmail_jimmy()
    // send an error to jimmy's mailbox
    echo "There is an error, mailing administrator now.";
    $mail = new Pop; // initiate new class
    $mail->setText("Help Desk Error","$dbn Thanksn The Help Desk"); //Subject; body
    $mail->sendMail(); // Send the mail

    if ($submit) {

    // process form

    $db = mysql_connect("localhost", "web", "web") or die(errmail_jimmy());

    end of code
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    The way you are calling the function, $db will always be zero as that is the only time it will be called.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Melbourne, Victoria, Australia
    Rep Power
    you can use

    global $db;

    inside your function and it will behave the same as if you were outside the function.

Similar Threads

  1. Uploading Files
    By vivekjain in forum ASP Programming
    Replies: 0
    Last Post: February 16th, 2004, 11:21 PM
  2. accessing an outside variable within a BEGIN block
    By Viper_SB in forum Perl Programming
    Replies: 5
    Last Post: February 13th, 2004, 03:08 AM
  3. Scriplet issue : accessing javascript function
    By creativedr in forum JavaScript Development
    Replies: 1
    Last Post: February 4th, 2004, 10:22 PM
  4. C: Passing a variable from function to another?
    By braty in forum C Programming
    Replies: 1
    Last Post: January 30th, 2004, 04:10 AM
  5. Replies: 1
    Last Post: January 25th, 2004, 08:33 PM

IMN logo majestic logo threadwatch logo seochat tools logo