Fork me on GitHub

Block causes PN admin area to fail  Bottom

  • I have modified an existing block to show all the categories and subcategories for the updownload module. It works great for the most part until you try to enter the admin area of PN. Here is the error:

    Fatal error: Call to a member function on a non-object in /home/maximstudios/public_html/proposals/productionco/includes/blocks/recentupdownload.php on line 51


    Here is the code for the block:

    Code

    $blocks_modules['recentupdownload'] = array(
        'func_display'      => 'blocks_updownload_block',
        'func_add'          => 'blocks_updownload_add',
        'func_edit'         => 'blocks_updownload_edit',
        'func_update'       => 'blocks_updownload_update',
        'text_type'         => 'Recent UpDownload v3',
        'text_type_long'    => 'Recent UpDownload v3',
        'allow_multiple'    => true,
        'form_content'      => false,
        'form_refresh'      => false,
        'show_preview'      => true
    );

    pnSecAddSchema('Recent_UpDownload::', 'Block title::');

    function blocks_updownload_block($row) {

        include_once 'modules/UpDownload/includes/config.php';
        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();

        $content .= "<div style=\"padding-top:3px;\">";

        $maindownload = 0;

        $column = &$pntable['updownload_categories_column'];
        $result =& $dbconn->Execute("SELECT $column[cid], $column[title], $column[cdescription]
                                FROM $pntable[updownload_categories]
                                ORDER BY $column[title]"
    );
        $numcats = $result->PO_RecordCount();

            // Main categories
        $content .= "<div style=\"text-align:left\">";

            $count = 0;
            while(list($cid, $title, $cdescription) = $result->fields) {

                $result->MoveNext();

                    $cresult = $dbconn->Execute("SELECT count(*) FROM ".$pntable['updownload_downloads'].
                    " WHERE ".$pntable['updownload_downloads_column']['cid']."=".pnVarPrepForStore($cid));

                    list($cnumrows) = $cresult->fields;
        $content .= "<div><h4 class=\"blocktitle\">".pnVarPrepForDisplay($title)."</h4></div>";
                    if (pnModGetVar('UpDownload', 'newdownloadgraphic')==1) {
                        categorynewdownloadgraphic($cid);
                    }
                    $column = &$pntable['updownload_subcategories_column'];
                    $sql = "SELECT $column[sid], $column[title]
                            FROM $pntable[updownload_subcategories]
                            WHERE $column[cid]="
    .pnVarPrepForStore($cid)."
                            ORDER BY $column[title]"
    ;

                    $result2 =& $dbconn->Execute($sql);

                    $space = 0;

                    while(list($sid, $stitle) = $result2->fields) {
                        $column = &$pntable['updownload_downloads_column'];
                        $resultnew =& $dbconn->Execute("SELECT count(*) FROM $pntable[updownload_downloads] WHERE $column[sid]=$sid");
                        list($numsubcats) = $resultnew->fields;

        $content .= "<div><a href=\"index.php?name=UpDownload&amp;req=viewsdownload&amp;sid=$sid\">".pnVarPrepForDisplay($stitle)."</a></div>";

                            $space++;
                            $result2->MoveNext();
                    }

            }

        $content .= "</div>";

        $row['content'] = $content;
        return themesideblock($row);
    }


    Its driving me nuts. Cant seem to find what would cause it. Hope someone can help.
  • which line is 51 ?
  • $numcats = $result->PO_RecordCount();
  • the block works fine though every where else except when in the general admin of PN. I can even use the admin area of the module. Im thinking it has something to do with the graphical admin interface of .760. But i have no clue y.
  • try to insert

    Code

    // Check for an error with the database code, and if so set an
        // appropriate error message and return
        if ($dbconn->ErrorNo() != 0) {
            echo 'Error  : ' . $dbconn->ErrorMsg();
        }

    Just after the line

    Code

    $result =& $dbconn->Execute("SELECT $column[cid], $column[title], $column[cdescription]
                                FROM $pntable[updownload_categories]
                                ORDER BY $column[title]"
    );

    And before the $numcats = $result->PO_RecordCount(); producing the error.
    If there is a problem with the query an error message will be displayed.

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • Well, i added the error code and it printed out:

    Code

    Error : You have an error in your SQL syntax. Check the manual that corresponds to your mysql server version for the right syntax to use near ' , FROM
    Fatal error: Call to a member function on a non-object in /home/maximstudios/public_html/proposals/productionco/includes/blocks/recentupdownload.php on line 58
  • could $pntables be causing it somehow?
  • you can find out

    echo out the variables and if you don't get all of the expected variables then it is a problem with pntables

    so for ex stick in there

    Code

    $content .= "cid=".$column[cid]." title=".$column[title]." cdesc=".$column[cdescription];

    And that will give you an output line that looks like:

    Code

    cid=[some value] title=[some value] cdesc=[some value]
  • its not the pntables, im lost
  • I gave up and hardcoded the DB calls, here is an example:

    Code

    $result =& $dbconn->Execute("SELECT pn_cid, pn_title
                                FROM main_updownload_categories
                                ORDER BY pn_title"
    );


    Its only for this site and module anyway. Works fine now.
  • My guess is that in fact pntables for the UpDownload module weren't loaded because it's an "old style" module. the error message

    Code

    Error : You have an error in your SQL syntax. Check the manual that corresponds to your mysql server version for the right syntax to use near ' , FROM

    show that the table's name is missing.
    Changing

    Code

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

    to :

    Code

    $dbconn =& pnDBGetConn(true);
      pnModDBInfoLoad('UpDownload');
      $pntable =& pnDBGetTables();

    Will solve the problem.

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • 0 users

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