3 Undefined Index Errors
Page 1 of 2 12 LastLast
Results 1 to 15 of 26

Thread: 3 Undefined Index Errors

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    18

    3 Undefined Index Errors

    Hi all.
    I was wondering if anyone could help me resolve 3 undefined index errors I keep getting.

    The errors are bellow as is the full PHP code of the page it refers to.

    I have been googling all day changing statements like empty to isset with no avail.

    I apreciate any help.

    The 3 errors
    15-04-2012, 15:39:03:: Unknown error type: [8] Undefined index: username on C:\Users\Nay\Desktop\server2go\htdocs\WeBid\admin\newadminuser.php line 59
    15-04-2012, 15:39:03:: Unknown error type: [8] Undefined index: password on C:\Users\Nay\Desktop\server2go\htdocs\WeBid\admin\newadminuser.php line 60
    15-04-2012, 15:39:03:: Unknown error type: [8] Undefined index: repeatpassword on C:\Users\Nay\Desktop\server2go\htdocs\WeBid\admin\newadminuser.php line 61
    15-04-2012, 15:39:03:: Unknown error type: [8] Undefined index: status on C:\Users\Nay\Desktop\server2go\htdocs\WeBid\admin\newadminuser.php line 62
    And here is the PHP
    PHP Code:
    <?php

    define
    ('InAdmin'1);
    $current_page 'users';
    include 
    '../includes/common.inc.php';
    include 
    $include_path 'functions_admin.php';
    include 
    'loggedin.inc.php';

    unset(
    $ERR);

    if (isset(
    $_POST['action']) && $_POST['action'] == 'update')
    {
        if (empty(
    $_POST['username']) || empty($_POST['password']) || empty($_POST['repeatpassword']))
        {
            
    $ERR $ERR_047;
        }
        elseif ((!empty(
    $_POST['password']) && empty($_POST['repeatpassword'])) || empty($_POST['password']) && !empty($_POST['repeatpassword']))
        {
            
    $ERR $ERR_054;
        }
        elseif (
    $_POST['password'] != $_POST['repeatpassword'])
        {
            
    $ERR $ERR_006;
        }
        else
        {
            
    // Check if "username" already exists in the database
            
    $query "SELECT id FROM " $DBPrefix "adminusers WHERE username = '" $_POST['username'] . "'";
            
    $res mysql_query($query);
            
    $system->check_mysql($res$query__LINE____FILE__);
            if (
    mysql_num_rows($res) > 0)
            {
                
    $ERR sprintf($ERR_055$_POST['username']);
            }
            else
            {
                
    $PASS md5($MD5_PREFIX $_POST['password']);
                
    $query "INSERT INTO " $DBPrefix "adminusers VALUES
                        (NULL, '" 
    addslashes($_POST['username']) . "', '" $PASS "', '" get_hash() . "', '" gmdate('Ymd') . "', '0', " intval($_POST['status']) . ")";
                
    $system->check_mysql(mysql_query($query), $query__LINE____FILE__);
                
    header('location: adminusers.php');
                exit;
            }
        }
    }

    loadblock($MSG['003'], '''text''username'$system->SETTINGS['username']);
    loadblock($MSG['004'], '''password''password'$system->SETTINGS['password']);
    loadblock($MSG['564'], '''password''repeatpassword'$system->SETTINGS['repeatpassword']);
    loadblock('''''batch''status'$system->SETTINGS['status'], array($MSG['566'], $MSG['567']));

    $template->assign_vars(array(
            
    'ERROR' => (isset($ERR)) ? $ERR '',
            
    'SITEURL' => $system->SETTINGS['siteurl'],
            
    'TYPENAME' => $MSG['25_0010'],
            
    'PAGENAME' => $MSG['367']
            ));

    $template->set_filenames(array(
            
    'body' => 'adminpages.tpl'
            
    ));
    $template->display('body');
    ?>
    Again Thanks

  2. #2
    Somewhere on Mars chrisguk's Avatar
    Join Date
    Jan 2010
    Location
    Someone tell me?
    Posts
    208
    This error appears because of your PHP error reporting settings. Usually, it appears when your variable is not properly set. There are two ways to handle this issue:

    1. Check if $_POST['action'] is set before using it. For example:

    PHP Code:
    if (!isset($_POST['action']))
    {
    //If not isset -> set with dumy value
    $_POST['action'] = "undefine";

    2. Suppress Notice warnings

    Notice warnings could be suppressed by changing the error_reporting variable in your PHP.ini. error_reporting could be set to show all errors except those for notices and coding standards warnings: error_reporting = E_ALL & ~E_NOTICE

    The same is accomplished by adding the following line in your php page:

    PHP Code:
    <?php error_reporting (E_ALL E_NOTICE); ?>
    Try not to become a man of success but a man of value

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Quote Originally Posted by chrisguk View Post
    This error appears because of your PHP error reporting settings. Usually, it appears when your variable is not properly set. There are two ways to handle this issue:

    1. Check if $_POST['action'] is set before using it. For example:

    PHP Code:
    if (!isset($_POST['action']))
    {
    //If not isset -> set with dumy value
    $_POST['action'] = "undefine";

    2. Suppress Notice warnings

    Notice warnings could be suppressed by changing the error_reporting variable in your PHP.ini. error_reporting could be set to show all errors except those for notices and coding standards warnings: error_reporting = E_ALL & ~E_NOTICE

    The same is accomplished by adding the following line in your php page:

    PHP Code:
    <?php error_reporting (E_ALL E_NOTICE); ?>
    Sorry I dont understand the code I posted is alredy checking for $_POST['action'] isset

  4. #4
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,915
    It is presumably complaining about these lines, and the indexes you are using for $system->SETTINGS:
    PHP Code:
    loadblock($MSG['003'], '''text''username'$system->SETTINGS['username']);
    loadblock($MSG['004'], '''password''password'$system->SETTINGS['password']);
    loadblock($MSG['564'], '''password''repeatpassword'$system->SETTINGS['repeatpassword']);
    loadblock('''''batch''status'$system->SETTINGS['status'], array($MSG['566'], $MSG['567'])); 
    So, you need to find out where $system is defined and determine why those elements are not set (or if they even should be).
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Thanks all for the help on this.

    I managed to fix a lot of the errors with this script but the one above I never did manage to resolve, however after reading threads on this forum and gogling I noticed that one of the include files common.inc.php had two error reporting variables open as bellow.

    $error_reporting = E_ALL^E_NOTICE;
    $error_reporting = E_ALL; //use this for debugging

    I realy think that the script makers ment that to be like I have changed it to like this

    $error_reporting = E_ALL^E_NOTICE;
    //$error_reporting = E_ALL; use this for debugging

    Having commented that code out the script now runs error free and the good thing is I managed to fix lots of other files errors along the way.

    Again thanks for the help

  6. #6
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,414
    Quote Originally Posted by nay27uk View Post
    Having commented that code out the script now runs error free
    ... no it doesn't, it's sweeping the error messages under the rug so that you never see them.

  7. #7
    Somewhere on Mars chrisguk's Avatar
    Join Date
    Jan 2010
    Location
    Someone tell me?
    Posts
    208
    Agree with Brad,

    In the short term "sweeping errors under the rug" may work fine but as your application grows or more users start using it then your script may fall over.

    I have sat for upto 18 hours and sometimes days to find errors, even if I have to go letter by letter to find it. Im all too aware of hiding errors to make my application look good but Im not a fan of painting a rusty car because eventually the rust will come through again.

    If a variable isnt defined you will get errors because the application needs it, so I would break down your code piece by piece to understand what needs to be defined and why. It's kind of like posting a letter with no address ("Where do you want me to go?")

    Dont get me wrong im certainly no PHP expert but through these forums and Google I have learnt those basic principles above.
    Try not to become a man of success but a man of value

  8. #8
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Thanks.

    It's not actualy my own script it is a GPL licenced auction script avaliable on the internet that I do a few mods and themes for as a regular member of the support forum.

    The support forum always has lots of errors posted asking how to resolve them, they guy that makes the script is only one guy and at the moment is very busy with taking exams and is also a family guy so finds it hard of late to get on the forums and resolve problems as well as working on the project, having said that the support this guy gives is second to none.

    Anyway to help this guy out and to help other members I decided to try and make the script stable and iron out all the errors, much of this I have managed to do, some of the fixes where already fixed by other members but never made it to the main download, hence my releasing a Service Pack and actualy updating the main download.

    I am now left with about 7 errors in the admin back end with that above variable turned on, I am not a PHP coder and find PHP to be to me like learning another language (almost imposible) so when I find an error and fix it to me it's a big thing.

    The above I spent two days trying to resolve and as the other member here pointed out it is the codes to do with loadblock, usualy the $system>settings variable pulls the said info from the database however the settings table in the database has no username, password, fields is all the settings table holds is general settings.

    Username, password stuff is held in tables users and adminusers, the above is a page in admin to add a new adminuser, the page is just a simple form with username, password, repeat password and status, status being do you want the new admin user to be active or non active.

    The loadblocks loads the form from another file called adminpages.php in otherwords the system somehow works out what kind of form fields need to be loaded depending on the form name and being as though we are trying to add a new adminuser the form onload should be empty.

    I hope this helps explain things a bit more clearly

  9. #9
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Sorry I ment to say that loadblocks comes from a file called adminfunctions.php its one of the included files at the begining of the above code

  10. #10
    Somewhere on Mars chrisguk's Avatar
    Join Date
    Jan 2010
    Location
    Someone tell me?
    Posts
    208
    Well if it's GPL then it would be easier to post it here and maybe one of the more experienced coders code see the problem for you or even me?
    Try not to become a man of success but a man of value

  11. #11
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Ok the $system variable is defined in includes/common.inc.php and is the following At line 17.
    PHP Code:
    $system = new global_class(); 
    The actual script is called WeBid and the support forum is HERE my username is nay27uk the founder of the script is called Renlock The script is a total ReWrite of the very old PHPauction that was GPL in about 1980.

    The original download verry buggy is HERE

    My service Pack is Here

    And the New main download hopefully error free, that he still needs to add to sorceforge is on one of my websites HERE Notice if you download and install this then open includes/common.inc.php and change line 17 from
    PHP Code:
    //$error_reporting = E_ALL; use this for debugging 
    back to
    PHP Code:
    $error_reporting E_ALL;  //use this for debugging 

  12. #12
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Can anyone please explain why I cant edit my posts

  13. #13
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    I ment to say that it was originaly PHPauction when it was owned by Gianluca Baldo when Renlock decided to download it and try to ReWrite it

  14. #14
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,414
    Quote Originally Posted by nay27uk View Post
    Can anyone please explain why I cant edit my posts
    See my first reply in this thread in the Feedback forum (and ignore the very last sentence - it doesn't apply to you... yet; sorry!).

  15. #15
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Quote Originally Posted by bradgrafelman View Post
    See my first reply in this thread in the Feedback forum (and ignore the very last sentence - it doesn't apply to you... yet; sorry!).
    Great thanks but I still dont see any EDIT button

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •