开发者

A public static function in a class not executing

I have a .php file with HTML code also in it. Through this file I am calling a function in another .php file that resides in a class. The call is not working. It is simply not entering the function in the class.

Below are the codes of first and second file respectively.

<div id="sectionGrid">  <!-- Begin of Grid Section -->
    <table id="tblGrid">
        <tr>
        <?php
            require("../Lib/displaygrid.php");
            displaygrid::SetGridWithValues("*","electioncategorymaster");
         ?>
        </tr>
    </table>
</div>  <!-- End of Grid Section -->

Above is just a section of the first file. Below is the second file entire code:

<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
<?php
final class displaygrid 
{
    public static function SetGridWithValues($columnNames,$tableName)
    {
                echo $columnNames;
                require 'obfusGrid.php';
                req开发者_JAVA技巧uire 'obfusGridSqlDAP.php';
                require("../Config/dbconfig.php");
                // Load the database adapter
                $db = new MySQLAdap(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
                // Load the datagrid class
                $x = new MyDataGrid($db);

                // Set the query
                $x->setQuery($columnNames, $tableName);

                // Add a row selector
                $x->addRowSelect("SetRowInCookie(%ID%);");
                echo $columnNames;
                // Apply a function to a row
                function returnSomething($ID)
                {
                    return strrev($id);
                }
                $x->setColumnType('ID', MyDataGrid::TYPE_FUNCTION, 'returnSomething', '%id%');

                // Print the table
                $x->printTable();

                //Show button to return to keywords entry page
                echo "<br><input id='backbutton' type='button' value='Back' onclick='ReturnBack()';>";
                echo "<script type='text/javascript'>alert(cookie['row_id']);</script>";        
    }
}
?>

I also want to know whether the links to other files are successfully implemented in the second code? I mean, the Link and Script tag on top.


I think you have a PHP error. Please turn on error_reporting. Can you try to remove the two lines on the top of this file ../Lib/displaygrid.php

<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">

Hope this helps! But turn on error reporting to see where the actual error is.


Maybe problems with include path?

try:

require dirname(__FILE__) . '/../Lib/path/to/required.file.php';


Use ini_set( 'display_errors', 1 ) and error_reporting ( E_ALL )


You have to remove the first two lines of file ../Lib/displaygrid.php for your code to work.

<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">

BTW, you should write cleaner code and avoid mixing presentation with code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜