Doc #80529 [Nab]: $mysqli->connect_errno may not work

From: Date: Thu, 17 Dec 2020 19:20:37 +0000
Subject: Doc #80529 [Nab]: $mysqli->connect_errno may not work
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18280@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80529&edit=1 ID: 80529 User updated by: bugs dot php dot net at latter dot org Reported by: bugs dot php dot net at latter dot org Summary: $mysqli->connect_errno may not work Status: Not a bug Type: Documentation Problem Package: MySQLi related PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: Definitely using the object. But we are trying to use the mysqli object inside an exception block. Seems to be some scope issues. Previous Comments: ------------------------------------------------------------------------ [2020-12-17 18:39:53] cmb@php.net Apparently, you are confusing new mysqli() with mysqli_connect(). ------------------------------------------------------------------------ [2020-12-17 18:18:21] bugs dot php dot net at latter dot org Description: ------------ --- From manual page: https://php.net/mysqli.construct --- This example code is given (as below) but if mysqli() returns false (as it will if for example the specified database does not exist) then $mysqli->connect_errno will generate a PHP warning of "Trying to get property 'connect_errno' of non-object". $mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db'); if ($mysqli->connect_errno) { die('Connect Error: ' . $mysqli->connect_errno); } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80529&edit=1

« previous php.doc.bugs (#18280) next »