php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70854 Mysqli connection problem
Submitted: 2015-11-04 14:50 UTC Modified: 2015-11-04 18:13 UTC
From: rmoisto at gmail dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 7.0.0RC6 OS: Ubuntu 15.10
Private report: No CVE-ID: None
 [2015-11-04 14:50 UTC] rmoisto at gmail dot com
Description:
------------
The select_db function does not work and produces a Warning when using a class that extends mysqli.

This worked perfectly with PHP 5.6. As I have both PHP versions installed on this computer I switched between them several times to confirm this.

I'm using PHP 7 RC6 that I compiled from source.
The web server is nginx, using PHP with FPM.

Test script:
---------------
<?php
class MyMysqli extends mysqli {
	public function e_select_db($db) {
		return $this->select_db($db);
	}
}

$mysqli = new MyMysqli('localhost', 'root', 'password');
$mysqli->e_select_db('db');

Expected result:
----------------
Database is selected.

Actual result:
--------------
Database is not selected.
Also, the following Warning is written to the error log:
PHP message: PHP Warning:  mysqli::select_db(): Couldn't fetch MyMysqli in /var/www/public_html/test.php on line 4" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock:", host: "localhost"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-04 15:04 UTC] rmoisto at gmail dot com
Seems I was not looking at my error log quite right, there's also an issue with connecting.

Simpler test script:
<?php
$mysqli = new mysqli('localhost', 'root', 'password');
$mysqli->select_db('db');

Full Warning:
2015/11/04 16:58:17 [error] 20107#0: *2075 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli::__construct(): (HY000/2002): No such file or directory in /var/www/enternum/public_html/test.php on line 2
PHP message: PHP Warning:  mysqli::select_db(): Couldn't fetch mysqli in /var/www/public_html/test.php on line 3" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock:", host: "localhost"
 [2015-11-04 15:26 UTC] rmoisto at gmail dot com
-Summary: Cannot change database +Summary: Mysqli connection problem -Status: Open +Status: Closed
 [2015-11-04 15:26 UTC] rmoisto at gmail dot com
Fixed by setting mysqli.default_socket in php.ini
 [2015-11-04 18:13 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 07:01:29 2024 UTC