Page 1 of 1

undefined variables

Posted: Tue Oct 19, 2004 10:00 am
by irealms
Hi any idea what server settings could cause php variables to show errors like this?

Code: Select all

Notice: Undefined variable: userid in /usr/home/sgerbitz/public_html/beta/index.php on line 6

Notice: Undefined variable: log in /usr/home/sgerbitz/public_html/beta/index.php on line 42

Notice: Undefined index: valid_user in /usr/home/sgerbitz/public_html/beta/i-auth.php on line 4
You are not logged in.
They are set in the format $_SESSION['variable'] or $variable. It doesn't do this on my server only on one a user has set up.

Posted: Tue Oct 19, 2004 10:10 am
by angrytuna
The "undefined variable" notices are indicators that you're using (surprise surprise) a variable that you haven't defined yet. The "undefined index" means you're indexing into an array with a key that you haven't defined yet. These are one of three types of error reporting that PHP can do. You'll have to change the error reporting level if you don't care that the variables are not instantiated, but you want the messages to disappear.
See http://us2.php.net/error_reporting

Posted: Tue Oct 19, 2004 10:17 am
by John Cartwright
you should not simply change the error reporting to not show it. Better yet, fix the problem, it is telling you the notice for a reason


for example

Code: Select all

<?php

if (isset($_POST['var']))
{

$_SESSION['var'] = $_POST['var'];

}

?>