I have reverted to addslashes(), even though $addslashes is defined. $addslashes is wrong in this context, and in some environments (e.g., my Debian Linux setup) will cause the password to be written out as an empty string and cause subsequent database connection failures. Since we are specifically trying to write a PHP string literal, we should be using PHP’s own addslashes.