Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts

    "Use of undefined constant" and $_POST['aaa']

    I wanted to update the company server from XAMPP 1.73 to 1.81 today, but thought, well, just do it at home first. And bongo, nothing works!

    PHP Code:
    // Sample #1:

    // Notice: Use of undefined constant date - assumed 'date' in C:\xampp\htdocs\bom3\scams\rthk.php on line 49

    $date = ($_POST['date']);

    // Sample #2:

    //Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 23
    //Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 24

    if($_POST['flg'] == 'ugg' ) {$bbb 'selected';} ELSE {$bbb '';}
    if(
    $_POST['flg'] == 'uggi' ) {$bbbi 'selected';} ELSE {$bbbi '';} 
    I get the message when I land on the page and the forms aren't filled.

    I think it may be related to isset, or the lack of it. Hope to get some hints here.
    Last edited by fail; 12-12-2012 at 03:07 AM.

  • #2
    Regular Coder Redcoder's Avatar
    Join Date
    May 2012
    Location
    /dev/null
    Posts
    334
    Thanks
    2
    Thanked 48 Times in 47 Posts
    You might as well as have an IF check because the $date is probably messing things up in some code somewhere else which is still being executed whether $_POST['date'] has anything or not.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This will not throw an undefined constant notice:
    PHP Code:
    // Sample #1:

    // Notice: Use of undefined constant date - assumed 'date' in C:\xampp\htdocs\bom3\scams\rthk.php on line 49

    $date = ($_POST['date']); 
    'date' has been properly identified as a string. Look elsewhere for this error for which you want to find the (undefined) constant date in use.

    PHP Code:
    // Sample #2:

    //Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 23
    //Notice: Undefined index: flg in C:\xampp\htdocs\bom3\scams\tool.php on line 24

    if($_POST['flg'] == 'ugg' ) {$bbb 'selected';} ELSE {$bbb '';}
    if(
    $_POST['flg'] == 'uggi' ) {$bbbi 'selected';} ELSE {$bbbi '';} 
    This one simply has no offset under the name 'flg'. Check it with isset before attempting to read it.

    Given the names in your filepaths here and the comparison criteria there, I'll sure raise question to future help requests.

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Given the names in your filepaths here and the comparison criteria there, I'll sure raise question to future help requests.
    ..it's a little tool for tracking scam stores that I use for some time. Nothing sinister. Just the move to the latest XAMPP messed things a little up.

    Now time to learn more about 'isset'.....

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Redcoder View Post
    You might as well as have an IF check because the $date is probably messing things up in some code somewhere else which is still being executed whether $_POST['date'] has anything or not.
    I presume the problem is that the date ain't set in the form when it first opens. Hence, blank forms seem to cause trouble in the latest XAMPP (or at least with a fresh installed XAMPP).

  • #6
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Solved the problem by using isset for each error at the beginning of the page:

    PHP Code:
    if (!isset($_POST['rthk']))   {    $_POST['rthk'] = ""; } 
    Another way is to change error_reporting = in xampp\php\php.ini

    But maybe a better way is to leave it in php.ini at the default error_reporting = E_ALL | E_STRICT and and use on your page i.e. error_reporting("E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR");

    I am aware that it's better to have all errors reported and just write better code.


  •  

    Posting Permissions

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