Tuesday 14 May 2019

cakephp - Unexpected T_FUNCTION in code, meaning?




I get an unexpected T_FUNCTION error on the $keyRows++ line.



    $mapArray = array();
$unifiedKeys = array();
$unifiedKeys = $this->query("select distinct FLOWSHEET_ID from FLOWSHEET_TEMPLATE;");
$keyRows = 1;
while ($row = mssql_fetch_assoc($unifiedKeys)) {

$mapArray['Method'.$keyRows] = array(

CaBase::KEY_MAPPING_LOGIC_COMPLEXITY => CaBase::LEVEL3_COMPLEXITY,
CaBase::KEY_FIELD_LOGIC_NAME => 'wsUnifiedKey' ,
//CaBase::KEY_FIELD_QUESTION_ID => $unifiedKeys($id_position))
CaBase::KEY_FIELD_QUESTION_ID => '$row[\"FLOWSHEET_ID\"]'
); //fixed error
$keyRows++;
}
return $mapArray;



1) What does this error mean? I get it quite a bit and I'm not sure how to debug it because I don't know what it means.



2) How should I go about fixing the error? I tried adding $this->keyRows++, but that didn't work either. Originally I was getting a "Can't use function return value in write context" error on this line, but I changed the $mapArray[] line to brackets instead of parentheses and now I'm getting the T_FUNCTION error.



ERROR IS NOW FIXED. But I am still curious as to what the T_FUNCTION error means/what to look for when it comes up.


Answer



The problem is ABOVE the $keyRows++. You didn't put the semicolon after an array. :D



$mapArray['Method'.$keyRows] = array(
CaBase::KEY_MAPPING_LOGIC_COMPLEXITY => CaBase::LEVEL3_COMPLEXITY,

CaBase::KEY_FIELD_LOGIC_NAME => 'wsUnifiedKey' ,
//CaBase::KEY_FIELD_QUESTION_ID => $unifiedKeys($id_position))
CaBase::KEY_FIELD_QUESTION_ID => '$row[\"FLOWSHEET_ID\"]'
);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...