• undefined variable charset in dbapi.mysql.class.inc.php on line 86#

  • mmjaeger Reply #1, 2 years, 7 months ago

    Reply
    Hello
    I don't know whether I'm doing something wrong or if there is an error somewhere

    when I echo the following:
    //$charset = $GLOBALS['database_connection_charset'];
    echo 'type: ' . gettype($this->config['charset']);
    $charset = $charset ? $charset : $this->config['charset'];

    I get "string" - if I just echo gettype($charset), I'm getting NULL?


  • opengeek Reply #2, 2 years, 7 months ago

    Reply
    The code you are showing there has the line which assigns the charset variable commented out I don't understand the problem here.


  • mmjaeger Reply #3, 2 years, 7 months ago

    Reply
    this is the original line in the file: $charset = $charset ? $charset : $this->config['charset']; that causes the error

    to fix it, I did the following change:
    //$charset = $charset ? $charset : $this->config['charset'];
    $charset = $this->config['charset'];


  • jjblack Reply #4, 2 years, 6 months ago

    Reply
    I received this very same error out of the blue. What causes it?


  • mmjaeger Reply #5, 2 years, 6 months ago

    Reply
    I fixed it like this:
    $charset = isset($charset) ? $charset : $this->config['charset'];


  • jjblack Reply #6, 2 years, 6 months ago

    Reply
    When I change it to your suggestion the site just comes up blank?? Does not even show the debug stuff which was:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: Undefined variable: charset
    Error type/ Nr.: Notice - 8
    File: /home/jbinfoman/modx1.magnabait.net/manager/includes/extenders/dbapi.mysql.class.inc.php
    Line: 86
    Line 86 source: $charset = $charset ? $charset : $this->config['charset'];

    When I change it back the debug works again showing the above?

    Lost here....any idea what is going on? Here are both lines I have tried on line 86 of the file:

    $charset = $charset ? $charset : $this->config['charset']; //this was the origional
    $charset = isset($charset) ? $charset : $this->config['charset']; //this was your recommended line

    using the second line I just get a blank site at my domain. The first yields the error above when debug is on to show it......



  • roele Reply #7, 2 years, 3 months ago

    Reply
    I fixed it with commenting out some of the last lines in index.php (renamed to default.php in my case because of a parallel installation). Hope this helps somebody...

    // execute the parser if index.php was not included
    //if (!MODX_API_MODE) {
        $modx->executeParser();
    //}
    ?>