Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undefined variable XXXXXX in e:\yyyy\xxxx\index.php 1

Status
Not open for further replies.

maccarone

Technical User
Jun 20, 2002
17
IT
I'm developing a new website for my church, and each time I use php scripts (downloaded by internet, free scripts) on my PC I get a lot of "Undefined variable" in various php file.
If I upload scripts to Linux system (where the website is hosted) all will work fine.
I took a look into php.ini file (under apache 1.3) but I didn't find any solution.

Could someone help me ???


 
The level of error reporting is set differently on the two installations. Compare the error level setting on the UNIX system (use phpinfo()) to your local settings.
Have a look at error reporting in the manual:
 
Thanks, but it is not only which error should be showed or not, but the script works only on linux/unix system but not on windows system.
 
What variable is giving you the "undefined variable" error?

If it's a singleton variable which is coming from a form, changes are that on the machine where the error occurs, register_globals is turned off but the script expects it to be "on".

A value from a form (for example a text field named "foo"), if register_globals is turned "on" will exist to your code as the singletone variable $foo. If register_globals is turned "off", $foo will not be created.

But in either case (assuming a POST-method form), the value will appear in the $_POST superglobal array as $_POST['foo'].

If this is the case, I strongly recommend that you modify the script so that it references elements in PHP's superglobal arrays rather than the singletons. There are security issues with running PHP with register_globals set to "on".



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
It might be just the he's using something like
Code:
$SomeVar = $_POST['some_name'];

If that is the case you can try either of:
Code:
$SomeVar = @$_POST['some_name'];

or
Code:
if (isset($_POST['some_name'])){
   $SomeVar = $_POST['some_name'];
}

Bastien

Cat, the other other white meat
 
I've checked the difference between my PC and the Linux server, where my site is hosted.
Below you can find the difference:
(In the brackets the original value in my PC)
session.bug_compat_42 on (off)
session.gc_divisor 100 (1000)
allow_call_time_pass_reference on (off)
error_reporting 2039 (2047)
magic_quotes_gpc on (off)
max_execution_time 120 (30)
max_input_time -1 (60)
register_argc_argv off (on)
register_globals on (off)
upload_max_filesize 10M (2M)

I don't think all values are important in my trouble, but for this and future issues I've changed them to line up my PC to server.

Now all the scripts work fine.

Thanks to all

 
This line:
register_globals on (off)
is the source of your problems. Up to version 4.0.3 (I think) register_globals was set to ON as the default after that it is set to OFF. When it is set to ON, PHP automagically creates variables from form variables. This can potentially be a security problem. When it is OFF, you have to request each value you want, i.e.
Code:
$xxx = $_POST['xxx'];
$yyy = $_GET['yyy'];
If you start programming with this in mind, your code will work whether it is set to ON or OFF.

Ken
 
I want to add a question....

I had the original same problem as maccarone, but once I changed the register_globals setting, nothing happend.

Well in other words I still get the same error message.

Any help would be great! I have been really struggling with this problem.

I have also been thinking that it might be a php e-mail problem. I copied this site from a linux server and moved it to a windows server and I am getting the "Undefined variable:" on every on of my text fields.
Thanks so much in advance!
 
can you show a piece of the code that is giving this error?

Bastien

Cat, the other other white meat
 
Stupid question-

Did you restart the server after you changed it from OFF to ON?

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top