Re: Interbase lob field on the web

From: Date: Mon, 13 Aug 2001 14:51:58 +0000
Subject: Re: Interbase lob field on the web
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11291@lists.php.net to get a copy of this message
"Alex.Tesi" <alex.tesi@plangroup.it> wrote in message news:003901c123fa$1ff2da50$7d50070a@coopitalia.net... >Hi i have a problem printing a lob field containing an image. >The database i use is Interbase 6.0 >I have a blob/lob field with a gif image inside an i like to print this image on the web. >Can you help me? You need a script to return the image, and you need to pass the proper parameter from the calling page... ======= image.php ========== <?php // check that param exists if (!isset($img)) { // alternatively, you could set img to // point to an 'error, not found' image // from your database... die("Error: 'img' parameter not set"); } // hacker prevention... $img = (int) $img; // connect to the database $conn = ibase_pconnect("host:dbase", "usr", "pwd") or die("Error: ".ibase_errmsg()); // query for image $query = "SELECT img_contents " ."FROM imgtable WHERE id=$img"; $res = ibase_query($conn, $query); // make sure that exactly one result was returned $num_returned = ibase_num_fields($res); if ($num_returned == 0) die("Error: specified image $img not found"); if ($num_returned > 1) die("Error: $num_returned images found for $img"); // return image // if you kept an image-type field in your // database, you could store and retrieve // various image types - gif, jpeg, bmp, png, // swf, svg, etc... header("Content-Type: image/gif"); $row = ibase_fetch_object($res); echo $row->img_contents; ?> ========================= =========== mypage.html ======= <html> <head> <title>Example...</title> </head> <body> <p>Here is image # 394302...</p> <img src='image.php?img=394302' align='center'> </body> </html> ===========================

« previous php.db (#11291) next »