Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.3

Bug #13 Connect broken Null PW in Mysql 4.0.15
Submitted: 2003-09-16 07:30 UTC
From: pear at richard-quinn dot com Assigned: danielc
Status: Closed Package: DB
PHP Version: 4.3.3 OS: WinXP
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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:
MUST BE VALID
Solve the problem : 50 - 19 = ?

 
 [2003-09-16 07:30 UTC] pear at richard-quinn dot com
Description: ------------ Pear::DB::Mysql::Connect does not send an empty $pw to *mysql_real_connect causing login failure. Fix below: Compare: (<)M:\dev\php4\PEAR\go-pear-bundle\mysql.php (27225 bytes) with: (>)M:\dev\php4\PEAR\DB\mysql.php (26542 bytes) 123c123,126 < $conn = @$connect_function($dbhost, $user); --- > $conn = @$connect_function($dbhost, $user, $pw); > if (empty($conn)) { > $conn = @$connect_function($dbhost, $user); > } 128c131,133 < } --- > } > > Reproduce code: --------------- You must be using Mysql v. 4. I use 4.0.15. Create a DSN with the following code: $user = 'root';$pass = '';$host = 'localhost';$db_name = 'mysql'; $dsn = "mysql://$user:$pw@$host/$db_name"; //echo (mysql_connect($host,$user)); Expected result: ---------------- A DB object, or more specifically a *string answer from MYSQL giving the resource ID. Actual result: -------------- Pear::DB say "connection failed". Closer analysis reveals MySQL saying "Password incorrect, use passwords is YES". The root user's password on a clean install is '' <zero length string>, but PEAR::DB cannot distinguish between an unset $pw and a $pw of no bytes, since this is all parsed by the DSN parser. So PEAR::DB sees that $pw is empty, and tries to connect without specifying the PW to *mysql_real_connect (a NULL is passed), which causes completely the wrong behaviour. MYSQL changed the NULL and EMPTY password behaviour in v. 4. - Rich

Comments

 [2004-01-03 17:51 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!