mysqli/Statement isn't valid anymore in x.php line #

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Is anyone familiar with what would cause an error like this:
Warning: Statement isn't valid anymore in includes\import.inc.php on
line 810

I'm using MySQL 4.1.2a, PHP 5.0.0 with Apache 2.0.50.  All tables are
InnoDB format.

The calling function is:
function insert_phone($ContactID) {
global $kTABLE_PREFIX;

foreach( $this->PhoneList as $addr ) {
	$db = DoMySQLConnect(); // connect
	$sql = "INSERT INTO {$kTABLE_PREFIX}phone (PhoneType, Phone,
Extension, ContactID) VALUES (?, ?, ?, ?)";
	if( !$stmt = $db->prepare($sql) ) { // prepare it
		printf("Error with %s:<br>%s<br>",$sql, $db->error );
	} else {
		if( !$stmt->bind_param("sssd", $addr->PhoneType,
$addr->Phone, $addr->Extension, $ContactID ) ) {
			printf("Error (#%d): %s;<br>%s<br>",
$stmt->errno, $sql, $stmt->error );
		} else {
			$stmt->execute(); // execute
			$stmt->free_result();
			$stmt->close();
		}
	}
	$db->close();
}
}

bind_param fails and I end up with:
Error (#0): INSERT INTO ap2004phone (PhoneType, Phone, Extension,
ContactID) VALUES (?, ?, ?, ?);

insert_phone is part of a class, Phone.

import.inc.php contains class definitions for a bunch of different
objects, contacts, email addresses, addresses etc that are being
massaged from a single flat table into relational tables.  There are
around 2000 inserts performed in a single import.  At the beginning of
the import I disable all foreign key checks etc 
	...
	$sql = 	"SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; "
		.	"SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; "
		. 	"SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; "
		. 	"SET NAMES utf8; "
		. 	"SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,
UNIQUE_CHECKS=0; "
		. 	"SET
@OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; "
		. 	"SET @OLD_SQL_MODE=@@SQL_MODE,
SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\"; ";

	$db = DoMySQLConnect();
	$db->multi_query($sql);
	$db->close();
	...

And at the end of the import I re-enable them.

As far as I can tell, there is nothing wrong with the INSERT statement,
or the variables it is inserting.  The errors appear randomly, and for
different objects at different times.  Occasionally there are no errors,
and then other times there are hundreds.  There are no mysql errors in
the mysql error log either.

Anyone have any ideas?  I'm going crazy :(

Thanks,
Corey

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux