Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Fix a MySQL error ($ in password)
This guide details the specific rules to follow when creating a user password with mysqli_connect()
that contains the “dollar” character $
on the Infomaniak platforms.
Preamble
- If you get the error message "Access denied for user" when using
mysqli_connect()
, and your database user password contains a$
sign, the issue may be due to the way strings work in PHP. - The issue may also occur with mail scripts.
Rules to follow
When the special character $
is used in a user password and is followed by any character other than a number, the variable name is not valid and the substitution does not occur correctly.
Here are some solutions to fix this:
- Enclose the password in single quotes:
'$******'
- Ensure that a number directly follows the dollar:
"$2*****"
- Use a backslash to "escape" the dollar sign in the password:
“\$****”
Link to this FAQ: