Hey guys.  Can I firstly say, thanks to all of you who helped me out with my
last question about importing MS Access databases into MySQL...  It helped
tons!

However, I have another question.

Firstly, I've strayed away from writing many of my own functions, because
they give me the fear.  But the code on the pages I am creating has forced
me to wake up...  I really sould think about cutting back on code.

SO, anyway, to cut to the chase, my question is this:  If I write a
function, which performs checks and assigns variable based on these checks,
how do I get the assigned variables from within the function?  For example
(this is more than likely VERY wrong), something like this:

global.inc:

<?

function CheckBirthday() {
  global $year,$month,$day;

    if (($day) && ($month) && ($year)) {
        if (checkdate($day,$month,$year) {
            $birthday = "$year/$month/$day";
        } else {
            $birthday = "Invalid";
        }
    }
}

?>

File that would update / insert information to a MySQL database:

<?

// Connection details here

require("global.inc");

CheckBirthday();

$sql = "UPDATE MyTable
        SET
        birthday = \"$birthday\"
        WHERE id = \"$id\"
        ";

// etc

?>

Even when I KNOW that I have included correct values, the $birthday variable
never shows up outside the function.  It's probably something simple I'm
missing, as in most cases ;)

Thanks for your patience,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to