Bug #73963 [Opn->Fbk]: mysqli_connect returns old object for invalid connection

From: Date: Fri, 20 Jan 2017 16:09:43 +0000
Subject: Bug #73963 [Opn->Fbk]: mysqli_connect returns old object for invalid connection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206763@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73963&edit=1

 ID:                 73963
 Updated by:         requinix@php.net
 Reported by:        thamizh82 at gmail dot com
 Summary:            mysqli_connect returns old object for invalid
                     connection
-Status:             Open
+Status:             Feedback
 Type:               Bug
-Package:            Output Control
+Package:            MySQLi related
 Operating System:   Linux
 PHP Version:        5.6.30
 Block user comment: N
 Private report:     N

 New Comment:

NULL for the host will assume localhost (which is documented), so
  mysqli_connect("localhost", $user, $pass)
  mysqli_connect(NULL, $user, $pass)
are the same.

The only thing suspicious is
  mysqli_connect("NULL", $user, $pass)
Are you absolutely certain that passing the string "NULL" gives you a working connection?
(And your system isn't resolving it to localhost.) The connection might be reused - what if you
don't connect successfully earlier?


Previous Comments:
------------------------------------------------------------------------
[2017-01-20 14:26:32] thamizh82 at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/function.mysqli-connect
---

$con=mysqli_connect("localhost","my_user","my_password","my_db");

var_dump($con);  -> Return mysql object.

$conn = mysqli_connect(NULL, $user, $pass);
$conn = mysqli_connect('NULL', $user, $pass);
Return Same/old object given before. Not thrown false or error.

$conn = mysqli_connect('NULLTest', $user, $pass);
Return false

Test script:
---------------
$con=mysqli_connect("localhost","my_user","my_password","my_db");

var_dump($con);  -> Return mysql object.

$conn = mysqli_connect(NULL, $user, $pass);
$conn = mysqli_connect('NULL', $user, $pass);
Return Same object given before. Not thrown false or error.

$conn = mysqli_connect('NULLTest', $user, $pass);
Return false

Expected result:
----------------

$conn = mysqli_connect(NULL, $user, $pass);

Should return false.

Actual result:
--------------

$conn = mysqli_connect(NULL, $user, $pass);

var_dump($con);  -> Return mysql object.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73963&edit=1


Thread (3 messages)

« previous php.bugs (#206763) next »