Hene
Hene

Reputation: 159

include class not working on server

I am including multiple files in my index.php

include($_SERVER['DOCUMENT_ROOT'].'include/feedback.php');
include($_SERVER['DOCUMENT_ROOT'].'include/order.php');
include($_SERVER['DOCUMENT_ROOT'].'include/customer.php');

and then trying to call a function for example from order.php like:

$order = order::find_open_orders_by_amount($db, 10);
    if (count($order) > 0) {
           for ($i = 0; $i < count($order); $i++) {

but the code stop running after order::find_open_orders_by_amount

I have also tried to include file like

include(dirname(__FILE__).'/../include/order.php');

in both cases the code stop executing in same line. Any suggestions?

order.php

<?php

class order {

    private $id;
    private $created;
    private $changes;
    private $finished;
    private $status;
    private $priority;
    private $resposible;
    private $changed_by;
    private $billed;
    private $paid;
    private $customer_id;
    private $description;

    public function getId() {
        return $this->id;
    }
    public function getCreated() {
        return order::format_date($this->created);
    }
    public function getChanged() {
        return order::format_date($this->changed);
    }
    public function getFinished() {
        return order::format_date($this->finished);
    }
    public function getStatus() {
        return $this->status;
    }
    public function getPriority() {
        return $this->priority;
    }
    public function getResponsible() {
        return $this->resposible;
    }
    public function getBilled() {
        return $this->billed;
    }
    public function getPaid() {
        return $this->paid;
    }
    public function getCustomerId() {
        return $this->customer_id;
    }
    public function getDescription() {
        return $this->description;
    }

    function order($id, $created, $changed, $finished, $status, $priority, $resposible, 
                          $billed, $paid, $customer_id, $description) {
        $this->id = $id;
        $this->created = $created;
        $this->changed = $changed;
        $this->finished = $finished;
        $this->status = $status;
        $this->priority = $priority;
        $this->resposible = $resposible;
        $this->billed = $billed;
        $this->paid = $paid;
        $this->customer_id = $customer_id;
        $this->description = $description;

    }
public function find_open_orders_by_amount($db, $amount) {
        echo 'asd';
        $i = 0;
        $orders = array();
        $conn = $db->getReadConnection();
        if ($conn) {
            $query = mysqli_query($conn, 'SELECT * FROM `order` WHERE finished IS NULL AND NOT status = 4 ORDER BY id LIMIT '. $amount);
            if (mysqli_num_rows($query) == 0) {
                echo mysqli_error($conn);
            } else {
                while ($row = mysqli_fetch_assoc($query)) {
                    $orders[$i++] = new order($row['id'], $row['created'], 
                                               $row['changed'], $row['finished'],
                                               $row['status'], $row['priority'], $row['responsible'],
                                               $row['billed'], $row['paid'], $row['customer_id'], $row['description']);
                }
            }
        }
        $db->closeDb($conn);
        return $orders;
    }
}
?>

Upvotes: 0

Views: 95

Answers (1)

vpx
vpx

Reputation: 108

Try to use require() instead of include()

http://www.php.net/manual/en/function.require.php

Upvotes: 1

Related Questions