I noticed that with the current php-cgi masked version (php-cgi-5.0.4) I am unable to use mysql 4.1 because enabling the mysql USE forces my system to downgrade mysql to version 4.0.24-r2 and mysqli is not yet supported. Both php and mod_php 5.1.0 ebuilds can have the mysql USE without downgrading mysql to 4.0.24-r2. Could you please upgrade php-cgi as you have done with php and mod_php?
Problem fixed by Stuart Herbert today.