Jump to content

Recommended Posts

I am using a PHP class for a web app that works perfectly well when developing on local machine (PHP 5.2) using the NuSphere IDE. NuSphere sees the class, and when I run the app locally everything seems to work, but when i port the app to the host (Linux Ubuntu with Apache2, PHP 5.3, MySQL 5.1 ), the class is not found (using the remote host debugger).

 

The exact mesage is: Class 'ExcelXML' not found at <line of code>.

 

Here is the code snippet:

<?php
    function setExcelData($sql, $title, $fileName, $idref=0)
    {
        $retVal=false;
        //$fileName=$fileName.'.xml';
        $fileName=$fileName.'.xls';
        include ('ExcelXML.inc.php');
        include_once $_SERVER['DOCUMENT_ROOT'].'/truck/inc/db.inc.php';
        $input = ($idref==0?"blank1.xml":"blank.xml"); 
        // create ExcelXML object
        $xml = new ExcelXML();
        // read template file
        if (!$xml->read($input))
        {
            echo "Failed to open Tempalate Excel XML file<br>";
        }
...
?>

 

Here is the class

<?php 
/**
* Class ExcelXML
* Provide functions to modify the content of file in Excel's XML format.
* 
* REQUIRED:
* - An ExcelXML file as template
* 
* FEATURES:
* - read, modify, and save Excel's XML file
* - create download stream as Excel file format (*.xls)
* 
* CHANGELOG:
* 06-08-2008
* - Update setCellValue function
* - Fix setCellValue bug
* 13-07-2008
* - First created 
* 
* 
* @author Herry Ramli (herry13@gmail.com)
* @license GPL
* @version 0.1.1
* @copyright August 06, 2008
*/
class ExcelXML
{
    var $domXML;
    var $activeWorksheet;
    
    function ExcelXML()
    {
    }
...
?>

 

The class is in the same folder location as the calling php file. Any ideas? I don't get it.

Link to comment
https://forums.phpfreaks.com/topic/236638-class-not-found-issue/
Share on other sites

Start stepping through your code and debugging.

 

Start by putting error_reporting(E_ALL) at the top of your main script.

 

Try echoing text from you ExcelXML classes page (not actually in the class). Just to make sure its being included etc.

Few observations along with comments from others:

 

1. In your code, the include statement for the class is missing with a starting single quote.

include('ExcelXML.inc.php');

 

If the above is not the issue, then:

2. This might be an issue with the location of the class file where you store it. In your localhost system, the file might be available through the "include_path" directive as set in the php.ini file. Now, if you stored the "ExcelXML.inc.php" in a folder, e.g. "includes" under your web root, include the class as follows:

include($_SERVER['DOCUMENT_ROOT'].'/includes/ExcelXML.inc.php');

 

If the class file is available in the same location as the calling script, then:

3. If your local system is Windows, then ExcelXML.inc.php and excelxml.inc.php might be same for the script, i.e. Windows is not case sensitive. So, if you can rename the file in the LINUX server to the exact casing as in the code, it will resolve your issue.

 

Hope, this might help you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.