|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47606 Access denied with double quotes
Submitted: 2009-03-09 16:06 UTC Modified: 2009-03-10 10:19 UTC
From: hugo at 1key dot nl Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.9 OS: Debian 4.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hugo at 1key dot nl
New email:
PHP Version: OS:


 [2009-03-09 16:06 UTC] hugo at 1key dot nl
mysql_connect("localhost", "user_name", "p@ssw'ord") or die (mysql_error());
/* Gives this error:
-- Access denied for user 'user_name'@'localhost' (using password: YES) */ ?>

please note the special characters in the password. When you try to connect using this command you get the error even though you can connect using phpmyadmin, commandline mysql etc.

When you change the double quotes to single quotes the problem is solved. It might be of interest to those used to set strings in double quotes.

mysql_connect('localhost', 'user_name', 'p@ssw\'ord') or die (mysql_error()); 
// Works perfectly 

It is not really a bug, or at least i can easily work around it, but I was not allowed to submit it as a usernote and got the message i should report a bug..

Reproduce code:
From manual page: function.mysql-connect
mysql_connect("localhost", "user_name", "p@ssw'ord") or die mysql_error());
/* Gives this error:
-- Access denied for user 'user_name'@'localhost' (using password: YES) 

Expected result:
A connection to the database

Actual result:
Access denied for user 'user_name'@'localhost' (using password: YES)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-10 10:19 UTC]
Bugs in phpmysql are not bugs in PHP.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Nov 29 12:01:26 2023 UTC