I am trying to customized the PHP so that the SQL can compare one of the ID fields to the current user's ID and only bring up users who have the same ID. I'm trying to do this by adding a function like the %%USERID%% in to the php. The problem I am having is that the block refuses to believe that the ID field I'm looking for exists.
My Code:
$sql = str_replace('%%AGENCYID%%', $USER->profile["agencyid"], $sql);
I tested the '$USER->profile["agencyid"]' bit on a different page and it echoed just fine. I've also attempted to assign it to a variable and even forced it into a string just to be safe. I've also tried json encoding/decoding it into an array and using $USER["profile"]["agencyid"] as well which again worked in the test page but only throws a read error when used in this block.
The exact error that I get is, "Error reading from database." I don't get any other information, even with debug mode on as it will get. I've tried replacing the %%USERID%% with the "agencyid" variables and I've tried shoving the %%AGENCYID%% in different places in the SQL just to make triple sure, but nothing has worked or given me any hint on what is wrong. Please help.