I've been looking into The Error From Hell, and seeing how I'm given the exact line number where the error occurs, I thought I'd start there.
So, line 136 from
$result = pg_query($sql);
So, to see the full query that's failing, I decide to print out the query just before it's made. And that's when I realize that the function this line appears in is called several times throughout the program (not all SQL calls are funneled through this function, just enough to make it painful).
Okay, approach the problem from a different angle. What's the function
that this piece of code is in? Oh, that's easy—
Okay, try a different approach.
The error complains about a syntax error near
contact_name_owner, so let's try looking for that. Thirty-one
loations where it's used, but none of them appear to construct a 3,544
character long SQL
statement, and the one place where such a statement might be
constructed, isn't called.
Meet Mr. Desk.
Mr. Desk? Meet my head.
I think I see the problem:
' ' AS contact_name , ' ' AS contact_id , ' ' contact_name_owner…
It seems as if there's a few missing
ASes in the
SQL Statement From
Hell, but not knowing where it's constructed (or even how), it's
not that easy to fix.
Or rather … there is a way …
Just before I call
pg_query(), scan the string, looking for
ASes and add them as required, maybe using some form of
regular expression search and replace funct—[at
this point, Sean's head exploded from even entertaining such a notion and
was pronounced “mostly dead” at the scene. Further updates as they