php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47935 mysql_connect( false, false, false ) return a resource
Submitted: 2009-04-09 11:00 UTC Modified: 2009-04-10 01:58 UTC
From: patomas at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.9 OS: Linux (Gentoo)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: patomas at hotmail dot com
New email:
PHP Version: OS:

 

 [2009-04-09 11:00 UTC] patomas at hotmail dot com
Description:
------------
Hi

If you try to connect to a database with mysql_connect( false, false, false ), the connection fails, but the command still generates a resource. I think that false would be a more accurate response since it can not stablish a real connection.

My php version is 5.2.8 but i couldn't choose it in the menu and I can't upgrade now.

Reproduce code:
---------------
var_dump( mysql_connect( false, false, false ) );

Expected result:
----------------
boolean false

Actual result:
--------------
resource(25, mysql link)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-09 13:20 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It logs in anonymously then, which in your case is apparently allowed.
 [2009-04-10 01:58 UTC] patomas at hotmail dot com
Hi

Thank you for your answer, but it still doesn't seem to be clear to me, can you point to the right documentation?.

Because, checking the documentation in http://us3.php.net/manual/en/function.mysql-connect.php you can read as follows:

[quote]
Return Values

Returns a MySQL link identifier on success, or FALSE on failure.
[/quote]

I may be wrong, but I think it is normal to expect a failure if you use false as a value for any of the connection parameters. First because if they are constants, it will depend on the value of each word, but if in any case, they fail, it is a failure. In the other hand, 'false' is a language constant with a predefined value, easily recognizable so we are passing something like 'no atribute' or 'incorrect atribute' to the connection.

If you try something like that in mysql console, in mysql-administrator or in any other interface, you get a Could not connect to host 'false' and MySQL Error Nr. 2005. Which in my mind and to my eyes, not to mention to mysql, looks like an error and the final result is that no connection is stablished.

So if this is not a failure, Can you, please, explain more detailed what is a failure in a command that should connect to a database?

References:
http://us3.php.net/manual/en/reserved.constants.php
http://us3.php.net/manual/en/language.types.boolean.php
http://us3.php.net/manual/en/function.mysql-connect.php
http://dev.mysql.com/doc/refman/5.1/en/error-messages-client.html
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 11 02:01:32 2024 UTC