strange mysqli error

From: Date: Tue, 22 Aug 2006 20:02:37 +0000
Subject: strange mysqli error
Groups: php.db 
Request: Send a blank email to php-db+get-42295@lists.php.net to get a copy of this message
Good afternoon. I'm getting a weird mysqli error in my object destructor. Here's an example: <?php $db = new mysqli('localhost', USERNAME, PASSWORD, DATABASE); class Test { function __construct() { global $db; $db->query("SELECT 'test'"); print_r($db->error); } function __destruct() { global $db; $db->query("SELECT 'test'"); // line 20 print_r($db->error); // line 21 } } $test = new Test(); ?> A. On my dev machine (Mac OS X + PHP 5.1.4 + MySQL 5.0.19) I get the following errors EVERY time: Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in /Users/richard/Projects/data/private/mgftest.php on line 20 Warning: Test::__destruct() [function.Test---destruct]: Couldn't fetch mysqli in /Users/richard/Projects/data/private/mgftest.php on line 21 B. On my production server (FreeBSD + PHP 5.1.2 + MySQL 5.0.19) I SOMETIMES get the following error: (If I refresh the page repeatedly, sometimes there's an error, sometimes not.) Warning: mysqli::query() [function.query]: Couldn't fetch mysqli in /usr/local/www/data/private/mgftest.php on line 20 C. On a commercial web host (PHP 5.0.4 + MySQL 5.0.22) I NEVER get any errors. There's nothing else in my error logs, $db-errno is 0, and $db->error is empty. Interestingly, I never get any errors from the constructor. Any ideas? Richard --- Richard K. Miller www.richardkmiller.com

« previous php.db (#42295) next »