php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43875 Two error messages returned for $new and $flag argument in mysql_connect()
Submitted: 2008-01-17 10:50 UTC Modified: 2008-01-21 18:45 UTC
From: josmessa at uk dot ibm dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 5.2CVS-2008-01-17 (snap) OS: Windows XP
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:
MUST BE VALID
Solve the problem:
33 + 42 = ?
Subscribe to this entry?

 
 [2008-01-17 10:50 UTC] josmessa at uk dot ibm dot com
Description:
------------
In the latest snapshot of PHP (this behaviour is *not* in PHP 5.2.5) there appears to be a stricter check on what can be passed as the $new and $flag argument in mysql_connect. If the wrong type of argument is passed then two error messages are returned. The first says that the parameter should be long, the second is a warning that the there is the wrong parameter count in mysql_connect(). I believe that this second error message is a bug as a) it contradicts the previous error message and b) it does not say what the correct parameter count is as it usually does with this type of error message.

Reproduce code:
---------------
<?php
$new = '';
$flag = 'string';
var_dump(mysql_connect('localhost', 'root', '', $new));
var_dump(mysql_connect('localhost', 'root', '', false, $flag));
?>

Expected result:
----------------
Warning: mysql_connect() expects parameter 4 to be long, string given in ...\mysql_connect.php on line 4
NULL

Warning: mysql_connect() expects parameter 5 to be long, string given in ...\mysql_connect.php on line 5
NULL


Actual result:
--------------
Warning: mysql_connect() expects parameter 4 to be long, string given in C:\Josie\Workspace\Bugs\mysql\mysql_connect.php on line 4

Warning: Wrong parameter count for mysql_connect() in C:\Josie\Workspace\Bugs\mysql\mysql_connect.php on line 4
NULL

Warning: mysql_connect() expects parameter 5 to be long, string given in C:\Josie\Workspace\Bugs\mysql\mysql_connect.php on line 5

Warning: Wrong parameter count for mysql_connect() in C:\Josie\Workspace\Bugs\mysql\mysql_connect.php on line 5
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-20 14:14 UTC] bjori@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2008-01-21 18:45 UTC] uw@php.net
Thanks for the bug report and the fix!

Once cause of this bug could be that we rarely check the actual error message for invalid parameters in our tests. Originally we did do that but then we had some issues writing portable tests and added @ to suppress the actual error message.

If run-tests.php ever gets rewritten, it would be cool if there would be a special way for checking warnings etc. (beyond regular expressions - or alternatively - different regexp for different PHP versions).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC