#29522 [Opn->Asn]: properties of mysqli (class) aren't accessable if db connection already closed
| From: | georg@php.net | Date: | Wed, 04 Aug 2004 11:58:45 +0000 |
| Subject: | #29522 [Opn->Asn]: properties of mysqli (class) aren't accessable if db connection already closed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64079@lists.php.net to get a copy of this message | ||
ID: 29522
Updated by: georg@php.net
Reported By: Nico dot Laus dot 2001 at gmx dot de
-Status: Open
+Status: Assigned
Bug Type: MySQL related
Operating System: Linux 2.6.7
PHP Version: 5.0.0
Assigned To: georg
Previous Comments:
------------------------------------------------------------------------
[2004-08-04 13:44:30] Nico dot Laus dot 2001 at gmx dot de
Description:
------------
when closing the connection to the db, and using
properties of the $mysqli object (such as insert_id), PHP
crashes (or even the webserver, I don't know)
-> although closing it before is not the right way, at
least an error message should be displayed
(took me a while to recognize that 1. some properties are
not accessible after disconnecting and 2. that this was
the reason for not showing the whole page)
Reproduce code:
---------------
// taken from
http://de2.php.net/manual/en/function.mysqli-insert-id.php
$mysqli = new mysqli('HOST', 'USER', 'PASSWORD','DB');
$mysqli->query("CREATE TABLE myCity LIKE City");
$query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU',
'Stuttgart', 617000)";
$mysqli->query($query);
/* close connection */
$mysqli->close();
printf ("New Record has id %d.\n", $mysqli->insert_id);
Expected result:
----------------
print out "New Record has id <id>"
Actual result:
--------------
"connection to <server> broken" error message from the
browser
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29522&edit=1