Bug #78870 [Com]: Connection errors appear in error.log

From: Date: Tue, 26 Jan 2021 06:42:26 +0000
Subject: Bug #78870 [Com]: Connection errors appear in error.log
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231773@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78870&edit=1 ID: 78870 Comment by: sylviareidvqee at gmail dot com Reported by: hhsnakeg at gmail dot com Summary: Connection errors appear in error.log Status: Open Type: Bug Package: MySQLi related PHP Version: 7.2.24 Block user comment: N Private report: N New Comment: pleased to see your issue as I think I have the same problem I am also confused and in need of light on this same issue. Need help. https://www.tellpopeyes.biz/ Previous Comments: ------------------------------------------------------------------------ [2019-12-16 15:23:19] hhsnakeg at gmail dot com To drtechno at mail dot com. Please read the contents carefully before commenting. It is a persist connection and errors that occur when using it. I wrote a simple example of how to repeat the error, as required by the bug report tracker. If it’s convenient for someone, you can skip connect(); 2 times, but in this case you will need to reload the page 2 times. Don't like a function call? write without a function, the meaning will not change. Please do not write nonsense if you do not understand the topic. Good luck. This connection style is used in the ADODB library. https://github.com/ADOdb/ADOdb/blob/master/drivers/adodb-mysqli.inc.php function _connect() lines 89-144 in current master branch. ------------------------------------------------------------------------ [2019-12-14 18:50:38] bugreports at gmail dot com > Just remember to use the procedural: mysqli_close($con); > or the object oriented: $mysqli -> close(); to close the > connection at the bottom of your php page please stop to educate closing mysql connections! PHP does it at it's own at the end of the request when it#s not a persistent connection and if you ever decide to use persistent connections by 'p:localhost' instead 'localhost' you will regret your mysqli_close() which is less smart than PHP ------------------------------------------------------------------------ [2019-12-14 18:05:03] drtechno at mail dot com I think you have something going on with the your function. you need to sense if it exists, and the connection scheme is installed (if you are looking for deployment) Try: a fixed version of the Procedure style in a function (which I would not recommend): function connect(){ if(!isset($connectionID)){ $connectionID = mysqli_init(); if (!$connectionID){die("mysqli_init failed");} mysqli_real_connect($connectionID,'localhost', 'dbuser', 'dbpass', 'dbscheme'); }} connect(); But you shouldn't use a connect in a function ever! You should always control the connection state, and close the connection at the end of page.... use "require" call then mysqli_close($con); at the end of working with the database, in your php page. But If you need to call a connection, within a page, I recommend checking it first: if(!isset($connectionID)){ $connectionID = mysqli_init(); $con= mysqli_real_connect($connectionID,'localhost', 'dbuser', 'dbpass', 'dbscheme'); } Here is an object oriented version: $mysqli = mysqli_init(); if (!$mysqli) {die("mysqli_init failed");} $con -> real_connect("localhost","dbuser","dbpass","my_db"); Just remember to use the procedural: mysqli_close($con); or the object oriented: $mysqli -> close(); to close the connection at the bottom of your php page. ------------------------------------------------------------------------ [2019-11-26 15:02:54] cmb@php.net Thanks! ------------------------------------------------------------------------ [2019-11-26 14:56:48] hhsnakeg at gmail dot com 1. use 7.2.24 2. use mysqlnd 5.0.12-dev - 20150407 - $Id: 3591daad22de08524295e1bd073aceeff11e6579 $ ($connectionID->get_client_info();) Package: php7.2-mysql Version: 7.2.24-1+ubuntu18.04.1+deb.sury.org+1 Provides: php-mysqli, php-mysqlnd, php-pdo-mysql, php7.2-mysqli, php7.2-mysqlnd, php7.2-pdo-mysql ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78870 -- Edit this bug report at https://bugs.php.net/bug.php?id=78870&edit=1

« previous php.bugs (#231773) next »