473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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("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;
........
Jul 17 '05 #1
0 1710

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: will taubin | last post by:
i would like my program to have a config.php with passwords and other stuff. i would like to have a functions.php to hold all my functions. i would like the functions.php to include/require...
10
by: Sandman | last post by:
I have a master-script that runs for every site I make, and it has a standard set of functions, but sometimes I would want to override that function for a particular site, but if I redefine it for...
5
by: NotGiven | last post by:
I have an file I call using: require_once() In this file I have variables I'd like to use in the calling page and functions called by that page. How can I do this? example:
2
by: J | last post by:
I have a page search.php which uses Top.php and Bottom.php to do most webpage stuff common to all pages. Top.php includes/requires KTConstants.php. Top.php can't see Constants/variables like...
3
by: mich dobelman | last post by:
I cannot reference the values in side of config.php $dbhost,$dbuser ,$dbpasswd ,$dbname why? <?php require_once('includes/db.php'); //db connection functions require_once('config.php'); ...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: joe t. | last post by:
My apologies, i'm not sure how to ask this question correctly, so i'll give the examples as i go. First, i *think* my problem is described here, but i may be misunderstanding:...
1
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And...
5
by: jeddiki | last post by:
Hello, I have been writing procedural php for a couple of years and I have quite lot of little scrips that I use in different large scripts. I'll give and example I display the category...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.