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
Avatar of David Favor
David Favor
Flag of United States of America image

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.
Avatar of David Schure
David Schure

ASKER

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

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

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



ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo