I am using a jQuery method to pass data to a php method and get a response so that I could re-use the returned data.
I am getting an error:
DO_LicenseCount: find: CHECK autofetchd
DO_LicenseCount: find: DONE
DO_LicenseCount: FETCH: a:1:{s:12:"LicenseCount";s:2:"10";}
DO_LicenseCount: fetchrow LINE: LicenseCount = 10
DO_LicenseCount: fetchrow: LicenseCount DONE
Fatal error: Cannot access empty property in C:\PROJECTS\BRIAN\AMS\Web Application\inc\pear\DB\DataObject.php on line 3780
I am using a WAMP stack - PHP 5.1.6 and PearPHP.
jQuery:
<script>
function GetLicenseCount()
{
var SoftwareTypeFK = document.getElementById("sldSoftwareTypeList").value;
var SoftwareNameFK = document.getElementById("SoftwareTypeList").value;
console.log(SoftwareTypeFK);
console.log(SoftwareNameFK);
$.ajax({
type: "GET",
url: "/AMS_LOCAL/Modules/SoftwareLicenseAllocations/GetLicenseCount.php",
data: {SoftwareTypeFK: SoftwareTypeFK, SoftwareFK: SoftwareNameFK},
success: function(result){
$("txtLicenseCount").text(result);
console.log(result);
}
});
};
</script>
GetLicenseCount.php:
<?php
//Local include path format
set_include_path('C:\PROJECTS\BRIAN\AMS\Web Application;C:\PROJECTS\BRIAN\AMS\Web Application\inc\pear;C:\PROJECTS\BRIAN\AMS\Web Application\js;');
//Search Screen
require_once('vars.php');
require_once('funcs.php');
$SoftwareTypeID = $_GET['SoftwareTypeFK'];
$SoftwareNameID = $_GET['SoftwareFK'];
var_dump($SoftwareTypeID);
var_dump($SoftwareNameID);
DO_Common::DebugLevel(5);
$LicenseCountOptions = DO_Common::toAssocArray(array(
//$LicenseCountOptions = DO_LicenseCount::toAssocArray(array(
'tableName' => 'LicenseCount'
,'selectAdd' => 'LicenseCount'
,'whereAdd' => 'SoftwareFK=' . $SoftwareNameID . ' AND sldSoftwareTypeFK=' . $SoftwareTypeID
));
var_dump($LicenseCountOptions);
echo $LicenseCountOptions;
var_dump($LicenseCountOptions);
?>
part of DataObject.php:
function toValue($col,$format = null)
{
if (is_null($format)) {
**return $this->$col;**
echo $col;
}
$cols = $this->table();
switch (true) {
case (($cols[$col] & DB_DATAOBJECT_DATE) && ($cols[$col] & DB_DATAOBJECT_TIME)):
if (!$this->$col) {
return '';
}
$guess = strtotime($this->$col);
if ($guess != -1) {
return strftime($format, $guess);
}
// eak... - no way to validate date time otherwise...
return $this->$col;
case ($cols[$col] & DB_DATAOBJECT_DATE):
if (!$this->$col) {
return '';
}
$guess = strtotime($this->$col);
if ($guess != -1) {
return strftime($format,$guess);
}
// try date!!!!
require_once 'Date.php';
$x = new Date($this->$col);
return $x->format($format);
case ($cols[$col] & DB_DATAOBJECT_TIME):
if (!$this->$col) {
return '';
}
$guess = strtotime($this->$col);
if ($guess > -1) {
return strftime($format, $guess);
}
// otherwise an error in type...
return $this->$col;
case ($cols[$col] & DB_DATAOBJECT_MYSQLTIMESTAMP):
if (!$this->$col) {
return '';
}
require_once 'Date.php';
$x = new Date($this->$col);
return $x->format($format);
case ($cols[$col] & DB_DATAOBJECT_BOOL):
if ($cols[$col] & DB_DATAOBJECT_STR) {
// it's a 't'/'f' !
return ($this->$col == 't');
}
return (bool) $this->$col;
default:
return sprintf($format,$this->col);
}
}
The problematic line is is the one enclosed in ** return $this->$col;
(line 3780).
I searched over Google and what I found is that I should turn return $this->$col;
to return $this->col;
, however this is found by default in the PEAR package and I did not do any modifications to the code. When I change it, a number of errors turn up.
Am I missing something I'm not seeing here?