Jump to content

Recommended Posts

GREETING:  Happy New Year, W3Schools!  I am looking forward to another year of online progress.  Hopefully many of the problems that I have been experiencing for the last year and a half will disappear with the addition of a brand new iMac that can handle the latest PHP and MySql software.  This said,  I remain the advanced novice that I am and very much hope that you will continue to stand by my side.

BACKGROUND:  Please find below a set of code that permits one new set of functionality, but destroys another.  The related error messages are provided beneath the code.

if (isset($_GET['refer_type']) && filter_var($_GET['refer_type'], FILTER_VALIDATE_INT)) {
$refer_type = $_GET['refer_type'];
} else {
    $refer_type = 0;
}
if (isset($_GET['panel_type']) && filter_var($_GET['panel_type'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) {
    $panel_type = $_GET['panel_type'];
    if (isset($_GET['lang_type']) && filter_var($_GET['lang_type'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) {
        $lang_type = $_GET['lang_type'];
    }
} else {
    $panel_type = 0;
}

ERROR MESSAGES:

[05-Jan-2020 04:10:40 UTC] PHP Notice:  Undefined variable: lang_type in /home/thege0/public_html/grammarcaptive.com/devcptv18rs/overview.html on line 99

QUESTION:  Can you see anything in the code line

if (isset($_GET['lang_type']) && filter_var($_GET['lang_type'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) {
    $lang_type = $_GET['lang_type'];
}

or elsewhere that could be triggering the error.  The code line just given is new and is clearly the initial, but maybe not the final source of the problem.

By the way, when the code was first introduced, it did not appear to create a problem.  Only several days later did the problem appear.

Roddy

 

Link to post
Share on other sites

The $lang_type variable is only being created on specific conditions, if these conditions are not met then you will get a warning. You should initialize $lang_type with a default value outside of all of the if statements.

  • Thanks 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...