You don't say how you are calling this function.
You would need to use it like this:
if (! ($conn = @pg_connect(...)))
db_connect_error($conn);
but I think your function would be more useful if it also
printed $php_errormsg. Incidentally, the '@' is no bearing
on whether your error function works or not; its only
function is to suppress the automatic printing of the
php error message by php itself.