Hello!
I want to thank everyone who replied to my question. I managed to solve my problem.
I followed Tomas' suggestion and added '::text' to query string. Ultimately, however, the problem was that the function existed in another schema. (Thanks, Tom, for pointing me to this direction!) What I did was to add another pg_query, just before the "main" query:
pg_query($yhteys, "SET search_path TO htyo;");
That did the trick!
Again, thanks for saving me hours of frustration.
Tuo