Skip to content
Advertisement

How to fix the message “Undefined variable…” in WordPress [closed]

a problem suddenly occur on my website https://kcstravels.org I’ve this error message “Notice: Undefined variable: gLWHJ9848 in /home/kcstra3473/public_html/wp-content/themes/sketch/404.php on line 1” on the top and other places… Really I don’t know what happened because everything worked well… So, I’ve tried to remove the “sketch” theme directory (and I precise that I don’t know how this theme is present in theme directory and my default theme is VisaHub) but also K.O, I get always the same message. How to fix that please… The link of my website

Screenshot of error

Advertisement

Answer

that is not ERROR , this is just Notice messages, in general you can get various feedback about your scripts by PHP as mentions bellow :

  • E_ERROR
  • E_WARNING
  • E_PARSE
  • E_NOTICE
  • E_CORE_ERROR
  • E_CORE_WARNING
  • E_COMPILE_ERROR
  • E_COMPILE_WARNING
  • E_USER_ERROR
  • E_USER_WARNING
  • E_USER_NOTICE
  • E_STRICT
  • E_RECOVERABLE_ERROR
  • E_DEPRECATED
  • E_USER_DEPRECATED
  • E_ALL

this message is an E_NOTICE message that says:

A run-time notice indicating that the script encountered something that could possibly be an error, although the situation could also occur when running a script normally.

so the messages don’t report very serious problems that need emergency action. anyway, This error means that within your code, there is a variable or constant which is not set. But you may be trying to use that variable. The error can be avoided by using the isset() function or by setting a default value for it (if you know what property makes the notices triggered exactly).
if you don’t know, you can disable notice messages by PHP (keep that in mind: its better to disable error logs and same them in the log file when you are in production) :

for disableing all error messages :

error_reporting(0);

and for customizing them you can :

error_reporting(E_ALL & ~E_NOTICE);

with the above function, you will get all error levels except the notice ones.

if you are curious about what event can causes this problem Suddenly I can say that this may have a variety of reasons:

  • changing PHP version by you or host providers
  • adding new features or plugin
  • changing error level by other scripts
  • changing in host config and …
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement