I am getting the error:
Parse error: syntax error, unexpected T_STRING in /mysite/my_library.php on line 43
However, I can not find any synatx errors in the code that it suggests:
/*
* Get Full Filter Name from Abbreviation
*/
function getFilterName ($filterAbbreviation) {
$filters = array(
"R" => "Restuarant",
"B" => "Bar",
"S" => "Store",
"L" => "Lodging",
"Q" => "Recreation",
"G" => "Gas Station",
"E" => "Entertainment",
"C" => "Club"
);
return $filters[$filterAbbreviation];
}
/*
* Parse Filterstring
*/
function parseFilterString($filterString) {
$returnVal = "";
$filterLetters = str_split($filterString, 1);
for($x = 0; $x < strlen($filterString); $x++) {
$returnVal .= "(type <=> '" . getFilterName($filterLetters[$x]) . "') OR ";
}
if (strlen($returnVal) > 0) $returnVal = substr($returnVal,0,-4); //remove final " OR " from filterstring
else $returnVal = "type = 'VOID'"; //if everything is filtered, make sure to set type to something not available
return $returnVal;
}
Please note this code is referenced from the page the user is querying using require().
The reason (in your case) is that your editor has inserted a hidden character in the text. (The editor is a computer program, and all computer programs go wrong, sometimes!). The clue was that it appeared to complaining about a space, but a space is not a string unless surrounded by quotes, so something is wrong. And what is wrong is that it’s not a space, but something else…
The solution is to remove this hidden character. The safest is to delete the line and retype it – but just in case the hidden character is within the end-line (CR/CRLF) markers, it’s best to delete the lines above and below as well.
So, select the line above, the offending line and the line below (all in one go, three lines together). Hit “delete”. Then TYPE (do not cut and paste), but use the keyboard to type the offending lines back in.
(Note – the this does not work, the error line may simply move. This is where delete fails to see the hidden character and only deletes the test it expects. The trick for this is to copy/paste everything execpt the offending line +/- 1 into another file, then type the offending line +/-1 into that new file. In your case, you didn’t need it, I’m just adding for completeness of answer).