php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73963 mysqli_connect returns old object for invalid connection
Submitted: 2017-01-20 14:26 UTC Modified: 2017-01-29 04:22 UTC
From: thamizh82 at gmail dot com Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: 5.6.30 OS: Linux
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
28 + 49 = ?
Subscribe to this entry?

 
 [2017-01-20 14:26 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-20 16:09 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: Output Control +Package: MySQLi related
 [2017-01-20 16:09 UTC] requinix@php.net
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?
 [2017-01-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 22:01:32 2024 UTC