Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WWWXXXAPC, docmd.close 2585, WWWXXXDOCO, nu vot, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text, how to setup procmail html2text, WWWXXXAPC., XXXCNZZZ



#1: Problems storing a blob using php.

Posted on 2010-11-07 16:18:13 by 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

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 */

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

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:
To unsubscribe:

Report this message