Doc #80529 [Opn->Nab]: $mysqli->connect_errno may not work
| From: | cmb@php.net | Date: | Thu, 17 Dec 2020 18:39:53 +0000 |
| Subject: | Doc #80529 [Opn->Nab]: $mysqli->connect_errno may not work | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18279@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
Updated by: cmb@php.net
Reported by: bugs dot php dot net at latter dot org
Summary: $mysqli->connect_errno may not work
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: MySQLi related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Apparently, you are confusing new mysqli() with mysqli_connect().
Previous Comments:
------------------------------------------------------------------------
[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