1

I am trying to create a new instance of a class in php but when I create the object and refresh the page everything goes white. I honestly don't know how best to ask this question because the class file is 711 lines long which I don't want to post here. I was looking for a way to upload a file but there doesn't seem to be a way so I am just going to add a small part of the class file. Below is my code.

$customer = new Customer(1);

Class file

class Customer extends VerySimpleModel
implements TemplateVariable {
      static $meta = array(
        'table' => CUST_TABLE,
        'pk' => array('cust_id'),
        'joins' => array(
            'location' => array(
                'constraint' => array('cust_id' => 'loc.cust_id'),
            ),
            'service' => array(
                'constraint' => array('service_level' => 'service.id'),
            ),
        ),
    );

    var $id; var $name; var $contact; var $fname; var $lname; var $isactive; 
    var $contact_phone; var $phone_number; var $fax_number; var $locations; 
    var $domain; var $service_level; var $row; var $address; var $_location = null;

    function __onload() {
        $time = null;
        if (isset($this->passwdreset) && $this->passwdreset)
            $time=strtotime($this->passwdreset);
        elseif (isset($this->added) && $this->added)
        $time=strtotime($this->added);

        if ($time)
            $this->passwd_change = time()-$time; //XXX: check timezone issues.
    }

    function __toString() {
        return (string) $this->getName();
    }

    function asVar() {
        return $this->__toString();
    }

    public static function getCustomer( $id ) {
        $instance = new self();
        $instance->loadByID( $id );
        return $instance;
    }

    public static function withRow( array $row ) {
        $instance = new self();
        $instance->fill( $row );
        return $instance;
    }

    protected function loadByID( $id ) {
        $row = $this->getInfoById( $id );
        $this->fill( $row );
    }

    protected function fill( array $row ) {
        $this->row=$row;
        $this->id=$row["cust_id"];
        $this->cust_name=$row["cust_name"];
        $this->domain=$row["domain"];
        $this->isactive=$row["isactive"];
        $this->service_level=$row["service_level"];
    }

    static function getVarScope() {
        return array(
            'name' => array('class' => 'Customer', 'desc' => __('Customer')),
            'contact' => 'Primary contact',
            'phone' => 'Phone number',
            'address' => 'Address',
            'isactive' => 'Active',
            'serviceLevel' => 'Service Level'
        );
    } 

    function getId() {
        if ($this->id) {
            return $this->id;
        }
        return $this->cust_id;
    }

    function getInfoById($id) {
        $sql='SELECT * FROM '.CUST_TABLE.' WHERE cust_id='.db_input($id);

        if(($res=db_query($sql)) && db_num_rows($res))
            return db_fetch_array($res);

        return null;
    }

    function getInfo() {
        return $this->row;
    }

    static function create($vars=false, &$errors=array()) {
        $cust = parent::create($vars);
        $cust->created = SqlFunction::NOW();

        return $cust;
    }

    static function __create($vars, &$errors) {
        $cust = self::create();
        $cust->update($vars, $errors);

        return isset($cust->id) ? $cust : null;
    }
}

Errors

[11-Mar-2016 15:05:13 UTC] PHP Warning: include(ICCLUDE_DIRclass.customer.php): failed to open stream: No such file or directory in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

[11-Mar-2016 15:05:13 UTC] PHP Warning: include(): Failed opening 'ICCLUDE_DIRclass.customer.php' for inclusion (include_path='./;C:/Websites/OSTickets/upload/include/;C:/Websites/OSTickets/upload/include/pear/') in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

[11-Mar-2016 15:05:13 UTC] PHP Fatal error: Class 'Customer' not found in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 28

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

[11-Mar-2016 15:05:13 UTC] PHP Warning: include(ICCLUDE_DIRclass.customer.php): failed to open stream: No such file or directory in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

[11-Mar-2016 15:05:13 UTC] PHP Warning: include(): Failed opening 'ICCLUDE_DIRclass.customer.php' for inclusion (include_path='./;C:/Websites/OSTickets/upload/include/;C:/Websites/OSTickets/upload/include/pear/') in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 3

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

[11-Mar-2016 15:05:13 UTC] PHP Fatal error: Class 'Customer' not found in C:\Websites\OSTickets\upload\include\staff\ticket-view.inc.php on line 28

[11-Mar-2016 15:05:13 UTC] PHP Stack trace:

[11-Mar-2016 15:05:13 UTC] PHP 1. {main}() C:\Websites\OSTickets\upload\scp\tickets.php:0

[11-Mar-2016 15:05:13 UTC] PHP 2. require_once() C:\Websites\OSTickets\upload\scp\tickets.php:546

Andrew LaPrise
  • 3,373
  • 4
  • 32
  • 50
  • You can probably find more information in the server error log or on the screen if you enable error display. – jeroen Mar 11 '16 at 14:56
  • You need to turn on error reporting - or look in your error log file. The WSOD (White Screen of Death) _usually_ indicates a parse error which means something is wrong in your script. – Farkie Mar 11 '16 at 14:56
  • [Enable error reporting in PHP](https://blog.flowl.info/2013/enable-display-php-errors/) – Daniel W. Mar 11 '16 at 14:57
  • Check your logfiles / enable errors. What do you see? – Blackbam Mar 11 '16 at 14:57
  • 1
    Possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) Specifically, [Nothing is seen. The page is empty and white.](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851). – IMSoP Mar 11 '16 at 14:57
  • The problem is that this is an open source program and the coders weren't very good at standards. I posted the errors above as they were too long to post here. – ManateeInfuser Mar 11 '16 at 15:10

1 Answers1

0

Sorry I made a dumb mistake apparently. The Include at the top is spelled wrong. The funny thing was that I copied and pasted that part so I have no idea how it got misspelled.