Search code examples
phpmysqlmysql-error-1045

Warning: mysql_connect(): Access denied for user '‎‎u1'?


This is extremely basic and I apologize for asking such a rookie question.

But I a getting this error:

Warning: mysql_connect(): Access denied for user '‎‎u1'@'172.16.3.139' (using password: YES) in /usr/local/pem/vhosts/103503/webspace/httpdocs/eirestudio-tools/crm/add-contact.php on line 53 

The user says ‎‎u1?

What does this mean?

Here is a sample connection below, note the user, why am I getting ‎‎u1?

mysql_connect('localhost', '‎‎user', 'pass');

Solution

  • why am I getting ‎‎u1?

    Were you expecting just ‘u1’? Where are you reading that string from?

    What seems to have happened is that you've got some invisible control characters in your config source somewhere. Specifically, the string ‘‎’ is what you get when you take a Unicode U+200E LEFT-TO-RIGHT MARK and encode it into UTF-8, then read it using the Windows-1252 codepage.

    This could happen if the username ‘u1’ was being read from a text file: your program might read it as bytes in cp1252 (the default codepage on Western machines), but a text editor would guess it to be UTF-8 and turn those bytes into U+200E characters, which you won't be able to see. I don't know where they originally came from, but you could try re-typing/replacing the source containing ‘u1’ to get rid of them.