Fork me on GitHub

New Module - blank page after initialisation?  Bottom

  • Hi forum,

    I'am developing a new module for the german red cross and currently stuck at getting my pninit.php to work.

    The pninit.php works as far as it creates the necessary database table, but when I try to initialisize it via the administration I get a Blank Page. After that I try to reload the site and it shows me the administration panel and the modules list, with "You are not authorized to carry out this operation" above it.

    Anyone can offer a hint?

    Sorry for my poor english...
  • safroe

    Hi forum,

    I'am developing a new module for the german red cross and currently stuck at getting my pninit.php to work.

    The pninit.php works as far as it creates the necessary database table, but when I try to initialisize it via the administration I get a Blank Page. After that I try to reload the site and it shows me the administration panel and the modules list, with "You are not authorized to carry out this operation" above it.

    Anyone can offer a hint?

    Sorry for my poor english...


    the you are not authorized, is for security, you cant refresh it.


    as far as the Blank Page, u should debug the script, to see how far it actually gets, and what variables are being passed
  • I don't get it, maybe could take a look. The problem seems to be the verification whether the database table creation failed or not. A var_dump($dbconn->ErrorNo() gives me 0, the SQL-command is correct and works...

    Code

    <?php

    function DRK_init() {
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        $fahrzeugtable = $pntable['_drk_fv_fahrzeug'];
        $fahrzeugcolumn = &$pntable['_drk_fv_fahrzeug_column'];
        $sql = "CREATE TABLE $fahrzeugtable ( $fahrzeugcolumn[FahrzeugID] TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
                                              $fahrzeugcolumn[FahrzeugKennzeichen] VARCHAR(12) NOT NULL DEFAULT '',
                                              $fahrzeugcolumn[FahrzeugArt] VARCHAR(32) NOT NULL DEFAULT '',
                                              $fahrzeugcolumn[FahrzeugEinheit] VARCHAR(32) NOT NULL DEFAULT '',
                                              PRIMARY KEY(FahrzeugID) )"
    ;
        $dbconn->Execute($sql);
        if($dbconn->ErrorNo() != 0) {
            pnSessionSetVar('errormsg', _CREATETABLEFAILED);
            return false;
        }  
        return true;
    }

    function DRK_delete() {
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        $sql = "DROP TABLE $pntable[_drk_fv_fahrzeug]";
        $dbconn->Execute($sql);
        if($dbconn->ErrorNo() != 0) {
            pnSessionSetVar('errormsg', _DROPTABLEFAILED);
            return false;
        }
        return true;
    }

    ?>
  • A var_dump($dbconn->ErrorNo()); outputs "int(0)", I think that is not the same as $dbconn->ErrorNo() = 0 because int(0) is an empty value and $dbconn->ErrorNo() = 0 is an integer value with 0 in it?
  • Do you acknowledge? Could anyone please confirm the rightness of my code?
  • Make sure there is no white-space or extra lines after the ?> ... this is a leading cause of white-screen errors in the init process, IMHO.

    Maybe try these as your first 2 lines in the init function:

    Code

    $dbconn  =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();


    ...overall, it looks like your function should work...I don't see anything throwing up a red flag, but my eyes are tired...
  • Do you also have the upgrade function? I think you have to have it present, even if it doesn't have any code in it.
  • Good idea jediping... I didn't think it was required, but nonetheless...even if just:

    Code

    function DRK_upgrade()
    {
       return true;
    }
  • Ah, that did work. I BIG thanks to you...
    Am I right that the & in:

    Code

    $dbconn  =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();

    gives me the first array-value?
  • What was is that worked...adding the upgrade function...or changing up the $dbconn...?

    The & doesn't give you the first array value...it gives you a reference to the database connection resource as a whole, if I understand it correctly.
  • Quote

    The & doesn't give you the first array value...it gives you a reference to the database connection resource as a whole, if I understand it correctly.


    Yes, you reference the object rather than creating a copy of it (which is what = does). This uses less memory, and also has some other applications, which I've used in the past and have now forgotten icon_rolleyes

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Then, if the reference is changed or altered, the original variable is also changed to reflect that, right?
  • I think the upgrade function and deleting all whitespaces after the ?>

This list is based on users active over the last 60 minutes.