Problems storing a blob using php.

Problems storing a blob using php.

am 07.11.2010 16:18:13 von Richard Riley

Debian squeeze, mysql Ver 14.14 Distrib 5.1.49, for debian-linux-gnu
(i486) using readline 6.1, PHP 5.3.3-2 with Suhosin-Patch (cli) (built:
Oct 21 2010 18:58:27).

I'm not sure if this group or the php one is more appropriate but
thought I would try here first as it is perhaps a mysql setting I am
missing.

I have been unable to get prepared statements to store a blob.

using this test code:-

function saveImage($event)
{
$stmt = getDB()->prepare("INSERT INTO images (image) VALUES (?)");
$null = NULL;
$stmt->bind_param("b", $null);
$fp = fopen("common-images/takeaway.png", "r");
while (!feof($fp)) {
$stmt->send_long_data(0, fread($fp, 8192)); /* I also tried get_file_contents */
}
fclose($fp);
$stmt->execute();
logtext($stmt->error);
}


I get the following error in my home brew log file: "Incorrect arguments to mysqld_stmt_execute"

I have checked that fp is valid.

My table is defined as follows:-

,----
| CREATE TABLE `images` (
| `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
| `fkey` int(10) unsigned DEFAULT NULL,
| `image` blob,
| `name` varchar(30) NOT NULL,
| `type` varchar(30) NOT NULL,
| PRIMARY KEY (`id`),
| KEY `deleteimages` (`fkey`),
| CONSTRAINT `deleteimages` FOREIGN KEY (`fkey`) REFERENCES `events` (`id`) ON DELETE CASCADE
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8
`----

I'm sure it must be something glaringly obvious but being a bit of a
noob to mysql I'm not sure what to do to narrow it down. I can set the
blob field directly. Its the send_long_data that seems to cause the arg
error at the execute phase.

Any debugging hits/configure hints would be much appreciated.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org