For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > August 2004 > scope problem using functions and require_once









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author scope problem using functions and require_once
NotGiven

2004-08-27, 8:55 pm

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("code2.php");

echo "name = ".var_name;

if($HTTP_POST_VARS['Submit']=='submit'){

$error = look_at_data($_POST); //**********
if ($error == "") {
$success = "User inserted successfully";
}
}

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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com