TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Notice: (http://www.talkphp.com/advanced-php-programming/5214-notice.html)

oshash 01-09-2010 10:00 AM

Notice:
 
:-):-/Can any body tell me wat is this error for plz
Notice: Undefined index: login in C:\wamp\www\kamsar_011208_server\registration\user \query\general_query.php on line 3
My general_query.php is
PHP Code:

<?php
// error is here--\/
if($_SESSION['login']=='true') { $include_where_clause " WHERE reg_id='$_SESSION[login_mem_reg_id]'"; }
else 
$include_where_clause "";

$sql_get_rel "SELECT * FROM " TABLE_RELATIONSHIPS  ;
$rs_get_rel $db->Execute($sql_get_rel);

$sql_get_pro "SELECT * FROM " TABLE_PROFESSIONS  ;
$rs_get_pro $db->Execute($sql_get_pro);

$sql_get_edu "SELECT * FROM " TABLE_EDUCATIONS  ;
$rs_get_edu $db->Execute($sql_get_edu);

$sql_get_sta "SELECT * FROM " TABLE_STATES  ;
$rs_get_sta $db->Execute($sql_get_sta);  //etc etc....


Parvus 01-09-2010 10:38 AM

if($_SESSION['login']=='true')

You are checking if the login session is true, but apparently there is no session with a name like that.
You could put a check before that line with: if(isset($_SESSION['login'])){}
to check if the login session exists or not.

oshash 01-09-2010 11:33 AM

But
 
But the problem is the page loads the home page loads with the same error(s) and when i put this code
PHP Code:

<?php  error_reporting(E_ALL & ~E_NOTICE)  ?>

in admin index.php this errors goes...!!!:-/
and when i try to login in admin page it logins without any username and password

Parvus 01-09-2010 12:09 PM

If you can access the admin page without logging in, it means that your not validating if the user is logged in or not.

You have to put a check around the whole admin page and not for 1 line of code.
PHP Code:

if(isset($_SESSION['login']) && $_SESSION['login']=='true'){
// Your admin code goes here



adamdecaf 01-09-2010 04:09 PM

When you run

PHP Code:

<?php  error_reporting(E_ALL & ~E_NOTICE);  ?>

You're changing how PHP displays errors, which will show or not show errors and PHP will ignore the error(s).

Rhinos 01-23-2010 05:41 PM

Basically what that warning is saying is that your trying to use an index of an array in a statement before you have actually defined the index.

So there are two ways you could overcome this. The first is the code that Parvus posted and the second way is by setting a default value for that index if it hasn't already been set yet (this method is better if you are referencing the index many times throughout your scripts.

PHP Code:

if (!isset($_SESSION['login'])) {
    
$_SESSION['login'] = 'false'// change to whatever default value you want
}

// ...

if ($_SESSION['login'] == 'true') {
    
// ...




All times are GMT. The time now is 04:36 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0