scope problem using functions and require_once

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NotGiven

    scope problem using functions and require_once

    Below is a code snippet I am having a hard time with. I rerquire code1.php
    and code 2.php.

    code1.php contains some variables the code needs.
    code2.php contains some functions I call from the function below,
    look_at_data().

    Line 4 "echo" below corrctly shows the var_name from code1.php. BUT, when I
    call it again at the end of the snippet below, it shows nothing.

    I even added another reference to code1.php in that function and it did not
    help.

    Why and what do I do about it?

    Many thanks in advance!

    =============== =============== =============== ===========

    require_once('. ./lk/code1.php');
    require_once("c ode2.php");

    echo "name = ".var_name;

    if($HTTP_POST_V ARS['Submit']=='submit'){
    $error = look_at_data($_ POST); //**********
    if ($error == "") {
    $success = "User inserted successfully";
    }
    }

    function look_at_data($f orm23_data) { //**********
    require_once('. ./lk/code1.php');
    echo "name = ".var_name;
    ........


Working...