Avatar of David Schure
David Schure asked on

PHP file not loading

This statement is not returning results to my index.php page.  In fact the page will not even open.    order.php

<?php
namespace Phppot;
use Phppot\DataSource; class Order {     private $ds;     function __construct()     {         require_once __DIR__ . '../lib/DataSource.php';         $this->ds = new DataSource();     }     function getAllOrders()     {         $query = "SELECT * FROM tbl_session";         $result = $this->ds->select($query);         return $result;     }     function getPdfGenerateValues($id)     {         //$query = "SELECT * FROM tbl_session WHERE therapist_id='" . $id . "'";       $query = "SELECT * FROM tbl_session WHERE therapist_id=1";         $result = $this->ds->select($query);         return $result;     }     function getOrderItems($session_id)     {         $sql = "SELECT    tbl_session.session_id,     tbl_session.session_date,     tbl_session.session_type,     tbl_session.session_status,     tbl_therapist.therapist_name,     tbl_therapist.therapist_street,     tbl_therapist.therapist_city,     tbl_therapist.therapist_state,     tbl_therapist.therapist_zip_code,     tbl_therapist.therapist_indy_fee,     tbl_therapist.therapist_couple_fee,     tbl_therapist.therapist_group_fee,     tbl_client.client_name FROM    tbl_session    INNER JOIN    tbl_therapist    ON        tbl_session.therapist_id = tbl_therapist.therapist_id    INNER JOIN    tbl_client    ON        tbl_session.client_id = tbl_client.client_id WHERE    tbl_session.session_status = Completed";     } }

Open in new window

index.php

The link

PHPSQL

Avatar of undefined
Last Comment
Scott Fell

8/22/2022 - Mon
David Favor

Simple solution.

1) Uncomment error_reporting(-1);

2) Visit page.

3) Refer to either your Apache error.log file or PHP error.log file which will show you the exact file name + line number raising the Fatal, which produces the 500 Internal error.
ASKER
David Schure

I added this line to both the Order.php and the index.php page
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Open in new window

Notice: Undefined variable: orderResult in /home/audiodigz/public_html/INVOICE/index.php on line 29

Warning: Invalid argument supplied for foreach() in /home/audiodigz/public_html/INVOICE/index.php on line 29 

This is where the trouble begins...
<?php foreach ($orderResult as $k => $v) { ?>
         <tr>
                    <td><?php echo $orderResult[$k]["session_id"];?></td>
                    <td class="text-right"><?php echo $orderResult[$k]["session_date"];?></td>
                    <td class="text-right"><?php echo $orderResult[$k]["client_name"];?></td>
                    <td class="text-right"><a target="_blank"
                        title="Generate Invoice"
                        href="invoice.php?id=<?php echo $orderResult[$k]["session_id"];?>"><?php echo $orderResult[$k]["session_id"];?></a></td>
                </tr>
         <?php }?>

Open in new window

This line for starters...
$orderResult = $orderModel->getAllOrders();

Open in new window

Scott Fell

David, something is missing from what you are providing. See the example and compare to what you are actually doing.

<?php


class Order
{


   function getAllOrders()
   
   {
   
      return "this is all the orders";
   
   }


}


$orderModel = new Order;


$orderResult = $orderModel->getAllOrders();


echo $orderResult;

Open in new window


From what you provided, I don't understand how you are getting to $orderModel?

$orderResult = $orderModel->getAllOrders();

Open in new window



Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question