"Trying to get the non object" error on using SLim Framework and NotORM

Hello there I have a problem in my code and I dont know what is the problem.
when I running my code, I receive this Slim Framework error:

“Trying to get property of non-object”

here is my code:
index.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require'includes/function.php';
require 'Slim/Slim.php';
\\Slim\\Slim::registerAutoloader();
$app = new \\Slim\\Slim();
$app->post("/pspayment_process/",function() use ($app){

    $date = $app->request()->post("date");
    uploadFile($date);
    });
$app->run();
?>

function.php

<?php
    include'dbcon.php';
    global $db;
    function uploadFile($date){
      global $db;
        $tbldate = $db->tbldate->select("date,ext")->order("id")->limit(1);
        $se = $tbldate->fetch();
        $d1 = $se['date'];
        $ext = $se['ext'];
        $diff = (dateDiff($date, $d1));
        $br = 5;
        //extNameUpdate($ext);
        $totaldiff = $diff * $br;
        $extname = ($ext + $totaldiff);
    #payment
    $pspayment = "LSPI_PSPAYM_$extname.txt";
    findPayment($:sick::sick:pspayment);

    $path = iROOT()."temp/".$pspayment;
    $file = fopen($path, "r") or exit("Unable to open file!");
    fclose($file);
    $openPspaym = fopen(iROOT()."/sales/$pspayment","r");

    # Sales
    $pssales = "LSPI_PSSALE_$extname.txt";
    findPayment($pssales);
    $path = iROOT()."temp/".$pssales;

    $file = fopen($path, "r") or exit("Unable to open file!");
    fclose($file);
    $openPssale = fopen(iROOT()."/sales/$pssales","r");

    $type ="02";
    $store = "0020020657"; //getStoreInfo($type);
              //echo $store."<br />";


    if($openPssale)
    {
        if($openPspaym)
        {
            $echo = 1;
            $echo2 = 1;
            while(!feof($openPspaym))
            {
                $data = fgets($openPspaym);
                $arr = $data;
                $ace = substr($arr,0,1);
                $abe = trim(substr($arr,1,10));

                if(($ace!=0) && ($abe==$store))
                {
                    $a = substr($arr,0,1);             //Activity Flag | F1
                    $b = substr($arr,1,10);         //Store Code | F2
                    $c = substr($arr,11,10);         //Store Currency | F3
                    $d = substr($arr,21,8);         //Sales Transaction Date | F4
                    $e = substr($arr,29,6);          //Sales Transaction Time | F5
                    $f = substr($arr,37,3);         //Sales Transaction Cash Register ID | F6
                    $g = substr($arr,40,10);         //Sales Transaction Number | F7
                    $h = substr($arr,50,4);         //Payment Type | F8
                    $i = substr($arr,54,4);            //Payment Mode | F9
                    $j = substr($arr,58,16);         //Payment Amount | F10
                    $ja = substr($j,0,10); $jb = substr($j,10,6); $jc = $ja . "." . $jb;
                    $k = substr($arr,74,10);         //Payment Currency | F11
                    $l = substr($arr,84,16);         //Payment Amount In Store Currency | F12
                    $la = substr($l,0,10); $lb = substr($l,10,6); $lc = $la . "." . $lb;
                    $m = substr($arr,100,12);         //Exchange Rate | F13
                    $ma = substr($m,0,6); $mb = substr($m,6,6); $mc = $ma . "." . $mb;
                    $n = substr($arr,112,20);         //Customer Number | F14
                    $o = substr($arr,132,20);         //Credit Card Number | F15
                    $p = substr($arr,152,40);         //Client Last Name | F16
                    $q = substr($arr,192,30);        //Client First Name | F17
                    $r = substr($arr,222,4);         //Sales Transaction Type | F18
                    $s = substr($arr,226,6);         //Sales Assistant Code | F19
                    $t = "";                         //Comments | F20
                    $u = substr($arr,332,10);         //Origin Store Code | F21
                    $v = substr($arr,342,3);         //Origin Sales Transaction Cash Register ID | F22
                    $w = substr($arr,345,10);         //Origin Sales Transaction Number | F23
                    $x = substr($arr,355,4);         //Cash Operation Reason Code | F24
                    $y = substr($arr,359,10);         //Brand | F25
                    $z = substr($arr,369,2);         //Number Of Payments| F26

                    $textdate = substr($d, 0, 4)."-".substr($d, 4, 2)."-".substr($d, 6, 2);

                        if($date == $textdate)
                        {
                                $select = $db->pssale->select("F8")
                                ->where("F8 = ?","$textdate")
                                ;
                                $count = count($select);


                            if(co_unt_payment($textdate)==0)
                            {
                                insertME($a,$b,$c,$d,$e,$f,$g,$h,$i,$jc,$k,$lc,$mc,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$y,$z);
                            }
                            else
                            {
                                if($echo == 1)
                                {
                                    deleteME($textdate);
                                }

                                insertME($a,$b,$c,$d,$e,$f,$g,$h,$i,$jc,$k,$lc,$mc,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$y,$z);

                            }

                        }
                        else
                        {
                            if($echo == 1)
                            {
                                 echo "Date and File Date does not match. Date : $date <br />File :  File Date : $textdate";
                            }
                        }

                        $echo ++;

                    }

                }

                fclose($openPspaym);

                while(!feof($openPssale))
                {
                    $data = fgets($openPssale);
                    $arr = $data;
                    $ace = substr($arr,0,1);
                    $abe = trim(substr($arr,11,10));

                    if(($ace!=0) && ($abe==$store))
                    {
                        $a = substr($arr,0,1);          //Activity Flag | F1
                        $b = substr($arr,1,10);          //Country Code | F2
                        $c = substr($arr,11,10);          //Store Code | F3
                        $d = substr($arr,21,6);         //Sales Assistant Code | F4
                        $e = substr($arr,27,20);         //Customer Number | F5
                        $f = substr($arr,47,4);         //Sales Transaction Type | F6
                        $g = substr($arr,51,10);         //Sales Transaction Number | F7
                        $h = substr($arr,61,8);         //Sales Transaction Date | F8
                        $i = substr($arr,69,6);         //Sales Transaction Time | F9
                        $j = substr($arr,77,3);         //Sales Transaction Cash Register ID | F10
                        $k = substr($arr,80,2);         //Sales Transaction Line Type | F11
                        $l = substr($arr,82,25);         //Product Code | F12
                        $m = substr($arr,107,25);         //Product Reference | F13
                        $n = substr($arr,132,4);         //Color Code | F14
                        $o = substr($arr,136,4);         //Size Code | F15
                        $p = substr($arr,140,8);         //SKU | F16
                        $q = substr($arr,148,15);        //Luggage Lock Number | F17
                        $r = substr($arr,163,15);         //Luggage Serial Number | F18
                        $s = substr($arr,178,4);         //Product Tax Code | F19
                        $t = substr($arr,182,4);         //Location Tax Code | F20
                        $u = substr($arr,186,20);         //Customer Legal Number | F21
                        $v = substr($arr,206,16);        //Quantity | F22
                        $w = substr($arr,222,10);        //Currency Code | F23
                        $x = substr($arr,232,8);         //Line Discount #1 Code | F24
                        $y = substr($arr,240,12);         //Line Discount #1 Amount | F25
                        $ya = substr($y,0,10); $yb = substr($y,10,2); $yc = $ya . "." .$yb;
                        $z = substr($arr,252,8);         //Line Discount #2 Code | F26
                        $aa = substr($arr,260,12);         //Line Discount #2 Amount | F27
                        $ba = substr($aa,0,10); $bb = substr($aa,10,2); $bc = $ba . "." .$bb;
                        $ab = substr($arr,272,8);        //Line Discount #3 Code | F28
                        $ac = substr($arr,280,12);         //Line Discount #3 Amount | F29
                        $ca = substr($ac,0,10); $cb = substr($ac,10,2); $cc = $ca . "." .$cb;
                        $ad = substr($arr,292,8);         //Global Discount #1 Code | F30
                        $ae = substr($arr,300,12);         //Global Discount #1 Amount | F31
                        $da = substr($ae,0,10); $db = substr($ae,10,2); $dc = $da . "." .$db;
                        $af = substr($arr,312,8);        //Global Discount #2 Code | F32
                        $ag = substr($arr,320,12);         //Global Discount #2 Amount | F33
                        $ea = substr($ag,0,10); $eb = substr($ag,10,2); $ec = $ea . "." .$eb;
                        $ah = substr($arr,332,8);         //Global Discount #3 Code | F34
                        $ai = substr($arr,340,12);         //Global Discount #1 Amount | F35
                        $fa = substr($ai,0,10); $fb = substr($ai,10,2); $fc = $fa . "." .$fb;

                        $textdate = substr($h, 0, 4)."-".substr($h, 4, 2)."-".substr($h, 6, 2);

                        if($date == $textdate)
                        {
                            $select = $db->pssale->select("F8")
                                ->where("F8 = ?","$textdate")
                                ;
                                $count = count($select);
                            if($count==0)
                            {
                                insertPssale($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$yc,$z,$bc,$ab,$cc,$ad,$dc,$af,$ec,$ah,$fc);
                            }
                            else
                            {
                                if($echo2 == 1)
                                {
                                    deletePssale($textdate);
                                }

                                insertPssale($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$yc,$z,$bc,$ab,$cc,$ad,$dc,$af,$ec,$ah,$fc);
                            }
                        }
                        else
                        {
                            if($echo2 == 1)
                            {
                                echo "Date and File Date does not match. Date : $date <br />File : $fname File Date : $textdate";
                            }
                        }
                            $echo2 ++;

                    }

                }
                fclose($openPssale);
            }
            else
            {
                patalastas( "$ppaymName not found.", 5000);
            }

        }
        else
        {
            patalastas( "$psaleName not found.", 5000);
        }
    }

         function co_unt_payment($textdate){
         global $db;
         $select = $db->pspaym->select("F4")
                                ->where("F4 = ?","$textdate");
                                $count = count($select);
                                return $count;

         }
         function iROOT() {
    return $_SERVER['DOCUMENT_ROOT']."/test/";
    }


         function findPayment($nemo) {
    $path = iROOT();
    $file = $path."temp/" . $nemo;
    $newfile = $path."sales/" . $nemo;

    if (!copy($file, $newfile)) {

    }
    else {

    }

}

         function findSale($nemo) {
    $path = iROOT();
    $file = $path."temp/" . $nemo;
    $newfile = $path."sales/" . $nemo;

    if (!copy($file, $newfile)) {

    }
    else {

    }
    }

          function getStoreInfo($type)
          {
        global $db;
        $getstore = $db->tbinfo->select("store_code")
                                ->where("sales_type = ?","$type")
                                ->where("active = ?","1");
        $n = null;
        foreach($getstore as $stores)
        {
          $n .= $stores['store_code'];
        }
        return $n;
          }
          function insertME($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$y,$z)
          {
         global $db;
         $data = array(
        "F1"=>$a,
        "F2"=>$b,
        "F3"=>$c,
        "F4"=>$d,
        "F5"=>$e,
        "F6"=>$f,
        "F7"=>$g,
        "F8"=>$h,
        "F9"=>$i,
        "F10"=>$j,
        "F11"=>$k,
        "F12"=>$l,
        "F13"=>$m,
        "F14"=>$n,
        "F15"=>$o,
        "F16"=>$p,
        "F17"=>$q,
        "F18"=>$r,
        "F19"=>$s,
        "F20"=>$t,
        "F21"=>$u,
        "F22"=>$v,
        "F23"=>$w,
        "F24"=>$x,
        "F25"=>$y,
        "F26"=>$z
        );
         $result = $db->pspaym->insert($data);
    }

    function deleteME($d)
    {
        //mysql_query("DELETE FROM pspaym WHERE F4='$d' ");
        global $db;
        $book = $db->pspaym($d);
        $book->delete();

    }
    function deletePssale($textdate)
    {
        global $db;
        $book = $db->pssale($textdate);
        $book->delete();
    }

    function insertPssale($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u,$v,$w,$x,$yc,$z,$bc,$ab,$cc,$ad,$dc,$af,$ec,$ah,$fc)
    {

    global $db;
       $data = array(
       "F1"=>$a,
       "F2"=>$b,
       "F3"=>$c,
       "F4"=>$d,
       "F5"=>$e,
       "F6"=>$f,
       "F7"=>$g,
       "F8"=>$h,
       "F9"=>$i,
       "F10"=>$j,
       "F11"=>$k,
       "F12"=>$l,
       "F13"=>$m,
       "F14"=>$n,
       "F15"=>$o,
       "F16"=>$p,
       "F17"=>$q,
       "F18"=>$r,
       "F19"=>$s,
       "F20"=>$t,
       "F21"=>$u,
       "F22"=>$v,
       "F23"=>$w,
       "F24"=>$x,
       "F25"=>$yc,
       "F26"=>$z,
       "F27"=>$bc,
       "F28"=>$ab,
       "F29"=>$cc,
       "F30"=>$ad,
       "F31"=>$dc,
       "F32"=>$af,
       "F33"=>$ec,
       "F34"=>$ah,
       "F35"=>$fc
       );
         $result = $db->pssale->insert($data);
    }


    function dateDiff($d1, $date)
    {
        // Return the number of days between the two dates:
        return round((strtotime($d1)-strtotime($date))/86400);
    }
?>

dbcon.php

<?php
include "NotORM.php";
$dns = "mysql:dbname=ayala;host=localhost";
$connection = new PDO($dns, "root", "root");
$db = new NotORM($connection);
?>

will you check out for me sir? I cannot find the answer for my problem. Thank you.

Hi,

Could you provide some more information please? Without knowing which part of the code is causing the error, it’s impossible to see what might be wrong.