|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 - 21 = ?
Subscribe to this entry?

 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 15:01:29 2024 UTC