php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hugo at 1key dot nl
New email:
PHP Version: OS:

 

 [2009-03-09 16:06 UTC] hugo at 1key dot nl
Description:
------------
<?php
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.

<?php
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
---
<?php
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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-10 10:19 UTC] jani@php.net
Bugs in phpmysql are not bugs in PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC