|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-10 10:19 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
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)