tags:

views:

75

answers:

4

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';
       require '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.

+3  A: 

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.

Pasta
+1  A: 

Maybe problems with include path?

try:

require dirname(__FILE__) . '/../Lib/path/to/required.file.php';
Dmitry Merkushin
+1  A: 

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

Josh Ribakoff
+1  A: 

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

Sergi