It is hard to say why you are getting this error without knowing what the query is that is not valid. To print out the query that is on this page you can add in some code just after the variable that holds the query is set like this:
$query_logo = sprintf("SELECT id, logo FROM company WHERE id = %s", GetSQLValueString($colname_logo, "int"));
This should let you see the query on the screen. You should be able to easily see what the issue is. If not post back with the query you get so we can check it out. Also, make sure that you look at the URL when the error occurs to make sure that it is happening on this page.