Help with PHP Script

Discussion in 'PHP' started by primster7, May 13, 2013.

  1. #1
    Hello,

    I get an error when updating a category name in a script.

    The error that I get is $parentPosition not defined in line 523

    Is there a simple way to fix it without turning off the PHP error messages?
     
    primster7, May 13, 2013 IP
  2. wren11

    wren11 Active Member

    Messages:
    89
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    53
    #2
    you can check it against:

    if it's a constant use:

    if (defined($parentPosition))
    {

    }


    if it's not a constant use:

    if (isset($parentPosition))
    {

    }
     
    wren11, May 13, 2013 IP
  3. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #3
    Constants in PHP do not have the $ sign.

    That is not an error, but rather a notice, which is safe to hide. Add this line to the beginning of your main file (config, header, etc..) to suppress notices.
    
    error_reporting(E_ALL ^ E_NOTICE);
    
    PHP:
    If changing your error levels is not possible/preferred, then do what wren11 said or always predefine your variables.
     
    ThePHPMaster, May 14, 2013 IP
  4. primster7

    primster7 Well-Known Member

    Messages:
    801
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Thanks for your response. If it is no big deal then I will just turn off the error stuff.
     
    primster7, May 14, 2013 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    This is like putting sticky tape over your car's "check engine" light. Hiding the problem doesn't fix it.

    This probably can be fixed properly by adding a single line of code. If you need help, please post your code.
     
    nico_swd, May 15, 2013 IP
  6. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #6
    If you are going to sell this script (this script will be used by someone else), you'd better fix it. Because sometimes on some hosting environment, PHP notice will be displayed :)
     
    xrvel, May 15, 2013 IP